Skip to content

Commit

Permalink
Merge pull request #32 from vrchat-community/1.4.0
Browse files Browse the repository at this point in the history
1.4.0 - Bakery types & fixed hanging Bakery issue
  • Loading branch information
Jordo authored Mar 25, 2024
2 parents faec590 + 21b9b61 commit 283e873
Show file tree
Hide file tree
Showing 22 changed files with 319 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ private static void OnHierarchyItemGUI(int id, Rect rect)
if (data == null || data.Objects == null) return;

var targetIndex = data.Objects.FindIndex(i =>
(i.Target as Component)?.gameObject.GetHashCode() == instance.GetHashCode() ||
(i.Target as GameObject)?.GetHashCode() == instance.GetHashCode());
i.Target != null && ((i.Target as Component)?.gameObject.GetHashCode() == instance.GetHashCode() ||
(i.Target as GameObject)?.GetHashCode() == instance.GetHashCode()));

if (targetIndex == -1)
{
Expand Down
44 changes: 39 additions & 5 deletions vrchat.jordo.easyquestswitch/Editor/EQS_Window.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using UnityEngine;
using System;
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
using EasyQuestSwitch.Fields;
using System.IO;
using UnityEditor.Build;

namespace EasyQuestSwitch
{

public class EQS_Window : EditorWindow
{
private const string version = "1.3.1";
private const string version = "1.4.0";

[MenuItem("Window/Easy Quest Switch")]
public static void ShowWindow()
Expand Down Expand Up @@ -47,6 +47,10 @@ private EQS_Data data {
private bool revealEQSdata = false;
private float sideOffset = 0f;
private bool showHierarchyIcon = true;
private bool promptForPlatformChange = true;

[NonSerialized]
private bool subscribedToEvents = false;

private void CreatePlatformDependantHeader(BuildTarget buildTarget)
{
Expand All @@ -69,8 +73,12 @@ private void CreatePlatformDependantHeader(BuildTarget buildTarget)
private void OnEnable()
{
serializedObject = null;
EditorSceneManager.activeSceneChangedInEditMode += OnSceneChanged;
Undo.undoRedoPerformed += OnUndoRedo;
if (!subscribedToEvents)
{
EditorSceneManager.activeSceneChangedInEditMode += OnSceneChanged;
Undo.undoRedoPerformed += OnUndoRedo;
subscribedToEvents = true;
}

minSize = new Vector2(512, 400);
CreatePlatformDependantHeader(EditorUserBuildSettings.activeBuildTarget);
Expand All @@ -95,6 +103,7 @@ private void OnEnable()
chosenListFormat = EditorPrefs.GetInt("EQS_ListFormat", 0); // 0 - Simple, 1 - Reorderable
sideOffset = EditorPrefs.GetFloat("EQS_HierarchySideOffset", 0f);
showHierarchyIcon = EditorPrefs.GetBool("EQS_ShowHierarchyIcon", true);
promptForPlatformChange = EditorPrefs.GetBool("EQS_PromptForPlatformChange", true);

if (data != null)
{
Expand All @@ -103,6 +112,16 @@ private void OnEnable()
}
}

private void OnDestroy()
{
if (subscribedToEvents)
{
EditorSceneManager.activeSceneChangedInEditMode -= OnSceneChanged;
Undo.undoRedoPerformed -= OnUndoRedo;
subscribedToEvents = false;
}
}

private void CreateEQS()
{
GameObject sceneRefGO = new GameObject("EQS_DATA");
Expand Down Expand Up @@ -429,6 +448,21 @@ private void OnGUI()
DestroyEQS();
}
}
EditorGUILayout.Space(10);
using (var changeOtherSettings = new EditorGUI.ChangeCheckScope())
{
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.LabelField(EQS_Localization.Current.SettingsPromptForPlatformChange, EditorStyles.wordWrappedLabel);
promptForPlatformChange = EditorGUILayout.Toggle(GUIContent.none, promptForPlatformChange);
}

if (changeOtherSettings.changed)
{
EditorPrefs.SetBool("EQS_PromptForPlatformChange", promptForPlatformChange);
}
}
EditorGUILayout.Space(10);
using (var changeHierarchySettings = new EditorGUI.ChangeCheckScope())
{
EditorGUILayout.LabelField(EQS_Localization.Current.SettingsHierarchy, EditorStyles.boldLabel);
Expand Down
20 changes: 12 additions & 8 deletions vrchat.jordo.easyquestswitch/Runtime/EQS_Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void OnChangedBuildTarget(BuildTarget newTarget)

public void Awake()
{
if (currentVersion > version)
if (Objects != null && currentVersion > version)
{
foreach (Data d in Objects)
{
Expand All @@ -133,16 +133,19 @@ public void Awake()

public void OnSceneOpened()
{
/*buildInfo.NewBuildTarget = EditorUserBuildSettings.activeBuildTarget;
if (buildInfo.CachedBuildTarget != buildInfo.NewBuildTarget && Objects != null)
buildInfo.NewBuildTarget = EditorUserBuildSettings.activeBuildTarget;
if (EditorPrefs.GetBool("EQS_PromptForPlatformChange", true))
{
string displayDialog = string.Format(EQS_Localization.Current.PopupTargetChanged, buildInfo.NewBuildTarget.ToString());
if (EditorUtility.DisplayDialog("", displayDialog, EQS_Localization.Current.PopupAccept, EQS_Localization.Current.PopupDecline))
if (buildInfo.CachedBuildTarget != buildInfo.NewBuildTarget && Objects != null)
{
ApplyTarget(buildInfo.NewBuildTarget);
buildInfo.CachedBuildTarget = buildInfo.NewBuildTarget;
string displayDialog = string.Format(EQS_Localization.Current.PopupTargetChanged, buildInfo.NewBuildTarget.ToString());
if (EditorUtility.DisplayDialog("", displayDialog, EQS_Localization.Current.PopupAccept, EQS_Localization.Current.PopupDecline))
{
ApplyTarget(buildInfo.NewBuildTarget);
buildInfo.CachedBuildTarget = buildInfo.NewBuildTarget;
}
}
}*/
}
}

public void ApplyTarget(BuildTarget newTarget)
Expand All @@ -169,6 +172,7 @@ public void ApplyTarget(BuildTarget newTarget)
}
}
}
buildInfo.CachedBuildTarget = newTarget;
Debug.LogFormat(EQS_Localization.Current.LogPrefix + EQS_Localization.Current.LogSwitchSuccess, newTarget);
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
}
Expand Down
1 change: 1 addition & 0 deletions vrchat.jordo.easyquestswitch/Runtime/EQS_Localization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class EQS_LocalizedLanguage
public string SettingsHierarchy;
public string SettingsHierarchyIconShow;
public string SettingsHierarchyIconOffset;
public string SettingsPromptForPlatformChange;

public string PopupDeleteWarning;
public string PopupTargetChanged;
Expand Down
8 changes: 8 additions & 0 deletions vrchat.jordo.easyquestswitch/Runtime/EQS_Types/Bakery.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#if UNITY_EDITOR && BAKERY_INCLUDED
using UnityEditor;
using UnityEngine;
using EasyQuestSwitch.Fields;

namespace EasyQuestSwitch.Types
{
[AddComponentMenu("")]
public class Type_Bakery_DirectLight : Type_Behaviour
{
[System.NonSerialized]
private BakeryDirectLight type;

public SharedColor color = new SharedColor();
public SharedFloat intensity = new SharedFloat();
public SharedFloat shadowSpread = new SharedFloat();
public SharedInt shadowSamples = new SharedInt();
public SharedFloat indirectIntensity = new SharedFloat();
public SharedBool antiAlias = new SharedBool();


public override void Setup(Object type)
{
base.Setup(type);
BakeryDirectLight component = (BakeryDirectLight)type;
color.Setup(component.color);
intensity.Setup(component.intensity);
shadowSpread.Setup(component.shadowSpread);
shadowSamples.Setup(component.samples);
indirectIntensity.Setup(component.indirectIntensity);
antiAlias.Setup(component.supersample);

}

public override void Process(Object type, BuildTarget buildTarget)
{
base.Process(type, buildTarget);
BakeryDirectLight component = (BakeryDirectLight)type;
component.color = color.Get(buildTarget);
component.intensity = intensity.Get(buildTarget);
component.shadowSpread = shadowSpread.Get(buildTarget);
component.samples = shadowSamples.Get(buildTarget);
component.indirectIntensity = indirectIntensity.Get(buildTarget);
component.supersample = antiAlias.Get(buildTarget);
}
}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#if UNITY_EDITOR && BAKERY_INCLUDED
using UnityEditor;
using UnityEngine;
using EasyQuestSwitch.Fields;

namespace EasyQuestSwitch.Types
{
[AddComponentMenu("")]
public class Type_Bakery_LightMesh : Type_Behaviour
{
[System.NonSerialized]
private BakeryLightMesh type;

public SharedFloat intensity = new SharedFloat();
public SharedColor color = new SharedColor();
public SharedInt samplesNear = new SharedInt();
public SharedInt samplesFar = new SharedInt();
public SharedBool selfShadow = new SharedBool();
public SharedFloat indirectIntensity = new SharedFloat();

public override void Setup(Object type)
{
base.Setup(type);
BakeryLightMesh component = (BakeryLightMesh)type;
intensity.Setup(component.intensity);
color.Setup(component.color);
samplesNear.Setup(component.samples);
samplesFar.Setup(component.samples2);
selfShadow.Setup(component.selfShadow);
indirectIntensity.Setup(component.indirectIntensity);
}

public override void Process(Object type, BuildTarget buildTarget)
{
base.Process(type, buildTarget);
BakeryLightMesh component = (BakeryLightMesh)type;
component.intensity = intensity.Get(buildTarget);
component.color = color.Get(buildTarget);
component.samples = samplesNear.Get(buildTarget);
component.samples2 = samplesFar.Get(buildTarget);
component.selfShadow = selfShadow.Get(buildTarget);
component.indirectIntensity = indirectIntensity.Get(buildTarget);
}
}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#if UNITY_EDITOR && BAKERY_INCLUDED
using UnityEditor;
using UnityEngine;
using EasyQuestSwitch.Fields;

namespace EasyQuestSwitch.Types
{
[AddComponentMenu("")]
public class Type_Bakery_PointLight : Type_Behaviour
{
[System.NonSerialized]
private BakeryPointLight type;

public SharedColor color = new SharedColor();
public SharedFloat intensity = new SharedFloat();
public SharedFloat shadowSpread = new SharedFloat();
public SharedBool physicalFalloff = new SharedBool();
public SharedFloat range = new SharedFloat();
public SharedInt samples = new SharedInt();
public SharedBool legacySampling = new SharedBool();
public SharedFloat indirectIntensity = new SharedFloat();


public override void Setup(Object type)
{
base.Setup(type);
BakeryPointLight component = (BakeryPointLight)type;
color.Setup(component.color);
intensity.Setup(component.intensity);
shadowSpread.Setup(component.shadowSpread);
physicalFalloff.Setup(component.realisticFalloff);
range.Setup(component.cutoff);
samples.Setup(component.samples);
legacySampling.Setup(component.legacySampling);
indirectIntensity.Setup(component.indirectIntensity);

}

public override void Process(Object type, BuildTarget buildTarget)
{
base.Process(type, buildTarget);
BakeryPointLight component = (BakeryPointLight)type;
component.color = color.Get(buildTarget);
component.intensity = intensity.Get(buildTarget);
component.shadowSpread = shadowSpread.Get(buildTarget);
component.realisticFalloff = physicalFalloff.Get(buildTarget);
component.cutoff = range.Get(buildTarget);
component.samples = samples.Get(buildTarget);
component.legacySampling = legacySampling.Get(buildTarget);
component.indirectIntensity = indirectIntensity.Get(buildTarget);
}
}
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#if UNITY_EDITOR && BAKERY_INCLUDED
using UnityEditor;
using UnityEngine;
using EasyQuestSwitch.Fields;

namespace EasyQuestSwitch.Types
{
[AddComponentMenu("")]
public class Type_Bakery_SkyLight : Type_Behaviour
{
[System.NonSerialized]
private BakerySkyLight type;

public SharedColor color = new SharedColor();
public SharedFloat intensity = new SharedFloat();
public SharedInt samples = new SharedInt();
public SharedBool hemispherical = new SharedBool();


public override void Setup(Object type)
{
base.Setup(type);
BakerySkyLight component = (BakerySkyLight)type;
color.Setup(component.color);
intensity.Setup(component.intensity);
samples.Setup(component.samples);
hemispherical.Setup(component.hemispherical);
}

public override void Process(Object type, BuildTarget buildTarget)
{
base.Process(type, buildTarget);
BakerySkyLight component = (BakerySkyLight)type;
component.color = color.Get(buildTarget);
component.intensity = intensity.Get(buildTarget);
component.samples = samples.Get(buildTarget);
component.hemispherical = hemispherical.Get(buildTarget);
}
}
}
#endif
Loading

0 comments on commit 283e873

Please sign in to comment.