diff --git a/VRCPrefabs/EasyQuestSwitch.meta b/EasyQuestSwitch.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch.meta rename to EasyQuestSwitch.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Data.cs b/EasyQuestSwitch/EQS_Data.cs similarity index 62% rename from VRCPrefabs/EasyQuestSwitch/EQS_Data.cs rename to EasyQuestSwitch/EQS_Data.cs index 79c04a7..c68d080 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Data.cs +++ b/EasyQuestSwitch/EQS_Data.cs @@ -1,119 +1,157 @@ -#if UNITY_EDITOR -using System; -using System.Collections.Generic; -using UnityEditor; -using UnityEditor.Build; -using UnityEngine; -using Object = UnityEngine.Object; -using EasyQuestSwitch.Types; -using System.Reflection; -using System.Linq; -using System.Collections; - -namespace EasyQuestSwitch -{ - - [ExecuteInEditMode] - public class EQS_Data : MonoBehaviour - { - - [Serializable] - public class Data - { - public Object Target; - public Type_Base Type; - public bool Foldout; - } - - public List Objects; - - public void ValidateData(int index) - { - Data data = Objects[index]; - if (data.Target != null) - { - if(data.Type != null) - { - // Target has been changed, remove current type and apply a new one - DestroyImmediate(Objects[index].Type); - Objects[index].Type = null; - Objects[index].Foldout = false; - } - - IEnumerable everyTypes = from t in Assembly.GetExecutingAssembly().GetTypes() where t.IsClass && t.Namespace == "EasyQuestSwitch.Types" select t; - // TODO: I wrote this while I was very sleep deprived due to crunch time for Vket 4, so expect an optimisation sometime in the future - for(int i = 0; i < everyTypes.Count(); i++) - { - FieldInfo field = everyTypes.ElementAt(i).GetField("type", BindingFlags.NonPublic | BindingFlags.Instance); - if (field == null) continue; - Type fieldType = field.FieldType; - /*if (data.Target.GetType().IsAssignableFrom(fieldType)) Debug.LogFormat("{0} is Assignable from {1} ? {2}", data.Target.GetType(), fieldType, data.Target.GetType().IsAssignableFrom(fieldType)); - if (data.Target.GetType().IsSubclassOf(fieldType)) Debug.LogFormat("{0} is Subclass of {1} ? {2}", data.Target.GetType(), fieldType, data.Target.GetType().IsSubclassOf(fieldType));*/ - if (data.Target.GetType() == fieldType) - { - Objects[index].Type = (Type_Base)gameObject.AddComponent(everyTypes.ElementAt(i)); - break; - } - } - if(Objects[index].Type == null) - { - for(int i = 0; i < everyTypes.Count(); i++) - { - FieldInfo field = everyTypes.ElementAt(i).GetField("type", BindingFlags.NonPublic | BindingFlags.Instance); - if (field == null) continue; - Type fieldType = field.FieldType; - if (data.Target.GetType().IsSubclassOf(fieldType)) - { - Objects[index].Type = (Type_Base)gameObject.AddComponent(everyTypes.ElementAt(i)); - break; - } - } - } - if(Objects[index].Type == null) - { - Debug.LogError("This is an unsupported component"); - Objects[index].Target = null; - Objects[index].Foldout = false; - return; - } - Objects[index].Type.Setup(Objects[index].Target); - Objects[index].Foldout = true; - } - else if (data.Target == null && data.Type != null) - { - // Target has been removed but not the corresponding type, remove the type - DestroyImmediate(Objects[index].Type); - Objects[index].Type = null; - Objects[index].Foldout = false; - } - } - - public BuildTarget CachedBuildTarget; // Last build target used in this scene - public BuildTarget NewBuildTarget; - - private void Update() - { - NewBuildTarget = EditorUserBuildSettings.activeBuildTarget; - if (CachedBuildTarget != NewBuildTarget && Objects != null) CheckTarget(NewBuildTarget); - CachedBuildTarget = NewBuildTarget; - } - - public void CheckTarget(BuildTarget newTarget) - { - if(newTarget == BuildTarget.StandaloneWindows64 || newTarget == BuildTarget.StandaloneWindows || newTarget == BuildTarget.Android) - { - foreach(Data d in Objects) - { - if(d.Type != null) d.Type.Process(d.Target, newTarget); - } - Debug.LogFormat("EasyQuestSwitch applied the scene changes of build target {0}", newTarget); - } - else - { - Debug.LogError("Switched to an unsupported build target."); - } - } - } - -} -#endif +#if UNITY_EDITOR +using System; +using System.Collections.Generic; +using UnityEditor; +using UnityEditor.Build; +using UnityEngine; +using Object = UnityEngine.Object; +using EasyQuestSwitch.Types; +using System.Reflection; +using System.Linq; +using System.Collections; + +namespace EasyQuestSwitch +{ + [ExecuteInEditMode, AddComponentMenu("")] + public class EQS_Data : MonoBehaviour + { + + [Serializable] + public class Data + { + public Object Target; + public Type_Base Type; + public bool Foldout; + } + + public List Objects; + + public void ValidateData(int index) + { + Data data = Objects[index]; + if (data.Target != null) + { + for(int i = 0; i < Objects.Count; i++) + { + if (i == index) continue; + if (Objects[i].Target == data.Target) + { + Debug.LogError(EQS_Localization.Current.LogComponentExists); + DestroyImmediate(Objects[index].Type); + Objects[index].Type = null; + Objects[index].Foldout = false; + Objects[index].Target = null; + return; + } + } + if(data.Type != null) + { + // Target has been changed, remove current type and apply a new one + DestroyImmediate(Objects[index].Type); + Objects[index].Type = null; + Objects[index].Foldout = false; + } + + IEnumerable everyTypes = from t in Assembly.GetExecutingAssembly().GetTypes() where t.IsClass && t.Namespace == "EasyQuestSwitch.Types" select t; + for(int i = 0; i < everyTypes.Count(); i++) + { + FieldInfo field = everyTypes.ElementAt(i).GetField("type", BindingFlags.NonPublic | BindingFlags.Instance); + if (field == null) continue; + Type fieldType = field.FieldType; + if (data.Target.GetType() == fieldType) + { + Objects[index].Type = (Type_Base)gameObject.AddComponent(everyTypes.ElementAt(i)); + break; + } + } + if(Objects[index].Type == null) + { + for(int i = 0; i < everyTypes.Count(); i++) + { + FieldInfo field = everyTypes.ElementAt(i).GetField("type", BindingFlags.NonPublic | BindingFlags.Instance); + if (field == null) continue; + Type fieldType = field.FieldType; + if (data.Target.GetType().IsSubclassOf(fieldType)) + { + Objects[index].Type = (Type_Base)gameObject.AddComponent(everyTypes.ElementAt(i)); + break; + } + } + } + if(Objects[index].Type == null) + { + Debug.LogError(EQS_Localization.Current.LogUnsupportedComponent); + Objects[index].Target = null; + Objects[index].Foldout = false; + return; + } + Objects[index].Type.Setup(Objects[index].Target); + Objects[index].Foldout = true; + } + else if (data.Target == null && data.Type != null) + { + // Target has been removed but not the corresponding type, remove the type + DestroyImmediate(Objects[index].Type); + Objects[index].Type = null; + Objects[index].Foldout = false; + } + } + + public BuildTarget CachedBuildTarget; // Last build target used in this scene + public BuildTarget NewBuildTarget; + + // Removed feature for Vket release, will be released in v1.2 + /*private void Start() + { + /*if(CachedBuildTarget != NewBuildTarget && Objects != null) + { + string displayDialog = string.Format(EQS_Localization.Current.PopupTargetChanged, NewBuildTarget.ToString()); + if(EditorUtility.DisplayDialog("", displayDialog, EQS_Localization.Current.PopupAccept, EQS_Localization.Current.PopupDecline)) + { + CheckTarget(NewBuildTarget); + } + } + }*/ + + private void Update() + { + NewBuildTarget = EditorUserBuildSettings.activeBuildTarget; + if (CachedBuildTarget != NewBuildTarget && Objects != null) CheckTarget(NewBuildTarget); + CachedBuildTarget = NewBuildTarget; + } + + public void CheckTarget(BuildTarget newTarget) + { + if(newTarget == BuildTarget.StandaloneWindows64 || newTarget == BuildTarget.Android) + { + for(int i = 0; i < Objects.Count; i++) + { + Data d = Objects[i]; + if(d.Target == null) + { + Debug.LogErrorFormat(EQS_Localization.Current.LogSwitchMissing, i); + } + else + { + try + { + d.Type.Process(d.Target, newTarget); + PrefabUtility.RecordPrefabInstancePropertyModifications(d.Target); + } + catch (Exception e) + { + Debug.LogErrorFormat(EQS_Localization.Current.LogSwitchFailure, i, d.Target.name, e.Message); + } + } + } + Debug.LogFormat(EQS_Localization.Current.LogSwitchSuccess, newTarget); + } + else + { + Debug.LogError(EQS_Localization.Current.LogSwitchUnsupported); + } + } + } + +} +#endif diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Data.cs.meta b/EasyQuestSwitch/EQS_Data.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Data.cs.meta rename to EasyQuestSwitch/EQS_Data.cs.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Localization.cs b/EasyQuestSwitch/EQS_Localization.cs similarity index 68% rename from VRCPrefabs/EasyQuestSwitch/EQS_Localization.cs rename to EasyQuestSwitch/EQS_Localization.cs index b64625b..ecd27c0 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Localization.cs +++ b/EasyQuestSwitch/EQS_Localization.cs @@ -1,67 +1,77 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace EasyQuestSwitch -{ - public class EQS_Localization - { - public EQS_LocalizedLanguage Current; - public EQS_LocalizedLanguage[] AvailableLanguages; - - [Serializable] - public class EQS_LocalizedLanguage - { - public string DisplayName; - - public string SettingsButton; - public string SettingsLanguage; - public string SettingsApplyPC; - public string SettingsApplyQuest; - public string SettingsRemoveEQS; - public string SettingsCacheWarning; - public string SettingsCacheButton; - public string SettingsExplanation; - public string SettingsFeedback; - public string SettingsGithub; - public string SettingsTwitter; - - public string PopupDeleteWarning; - public string PopupAccept; - public string PopupDecline; - - public string ListSetupEQS; - public string ListExpand; - public string ListFold; - - public string LogUnsupportedComponent; - public string LogSwitchSuccess; - public string LogSwitchFailure; - } - - public void LoadLanguages() - { - UnityEngine.Object[] JSONlanguages = Resources.LoadAll("EQS_Local", typeof(TextAsset)); - AvailableLanguages = new EQS_LocalizedLanguage[JSONlanguages.Length]; - for(int i = 0; i < JSONlanguages.Length; i++) - { - AvailableLanguages[i] = JsonUtility.FromJson(JSONlanguages[i].ToString()); - } - Current = AvailableLanguages[0]; - } - - public string[] GetLanguages() - { - string[] languagesArray = new string[AvailableLanguages.Length]; - for(int i = 0; i < AvailableLanguages.Length; i++) - { - languagesArray[i] = AvailableLanguages[i].DisplayName; - } - return languagesArray; - } - - public void SetLanguage(int i) => Current = i < AvailableLanguages.Length ? AvailableLanguages[i] : AvailableLanguages[0]; - - } +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace EasyQuestSwitch +{ + public static class EQS_Localization + { + public static EQS_LocalizedLanguage Current; + public static EQS_LocalizedLanguage[] AvailableLanguages; + + [Serializable] + public class EQS_LocalizedLanguage + { + public string DisplayName; + + public string SettingsButton; + public string SettingsLanguage; + public string SettingsListFormat; + public string[] SettingsListFormatArray; + public string SettingsApplyPC; + public string SettingsApplyQuest; + public string SettingsRemoveEQS; + public string SettingsCacheWarning; + public string SettingsAssetPipelineV2; + public string SettingsCacheButton; + public string SettingsExplanation; + public string SettingsDebugOptions; + public string SettingsDebugReveal; + public string SettingsFeedback; + public string SettingsGithub; + public string SettingsTwitter; + + public string PopupDeleteWarning; + public string PopupTargetChanged; + public string PopupAccept; + public string PopupDecline; + + public string ListSetupEQS; + public string ListExpand; + public string ListFold; + + public string LogUnsupportedComponent; + public string LogComponentExists; + public string LogSwitchMissing; + public string LogSwitchFailure; + public string LogSwitchSuccess; + public string LogSwitchUnsupported; + } + + public static void LoadLanguages() + { + UnityEngine.Object[] JSONlanguages = Resources.LoadAll("EQS_Localizations", typeof(TextAsset)); + AvailableLanguages = new EQS_LocalizedLanguage[JSONlanguages.Length]; + for(int i = 0; i < JSONlanguages.Length; i++) + { + AvailableLanguages[i] = JsonUtility.FromJson(JSONlanguages[i].ToString()); + } + Current = AvailableLanguages[0]; + } + + public static string[] GetLanguages() + { + string[] languagesArray = new string[AvailableLanguages.Length]; + for(int i = 0; i < AvailableLanguages.Length; i++) + { + languagesArray[i] = AvailableLanguages[i].DisplayName; + } + return languagesArray; + } + + public static void SetLanguage(int i) => Current = i < AvailableLanguages.Length ? AvailableLanguages[i] : AvailableLanguages[0]; + + + } } \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Localization.cs.meta b/EasyQuestSwitch/EQS_Localization.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Localization.cs.meta rename to EasyQuestSwitch/EQS_Localization.cs.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types.meta b/EasyQuestSwitch/EQS_Types.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types.meta rename to EasyQuestSwitch/EQS_Types.meta diff --git a/EasyQuestSwitch/EQS_Types/EQS_Fields.cs b/EasyQuestSwitch/EQS_Types/EQS_Fields.cs new file mode 100644 index 0000000..57ccc8e --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/EQS_Fields.cs @@ -0,0 +1,164 @@ +#if UNITY_EDITOR +using System; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering; + + +namespace EasyQuestSwitch.Fields +{ + [Serializable] + public class SharedObject + { + public T PC; + public T Quest; + + public void Setup(T obj) + { + PC = Quest = obj; + } + + public T Get(BuildTarget buildTarget) + { + switch(buildTarget) + { + case BuildTarget.StandaloneWindows64: + return PC; + case BuildTarget.Android: + return Quest; + default: + return default(T); + } + } + } + + [Serializable] + public class SharedBool : SharedObject {} + [Serializable] + public class SharedInt : SharedObject {} + [Serializable] + public class SharedVector2 : SharedObject {} + [Serializable] + public class SharedVector2Int : SharedObject {} + [Serializable] + public class SharedVector3 : SharedObject {} + [Serializable] + public class SharedVector3Int : SharedObject {} + [Serializable] + public class SharedVector4 : SharedObject {} + [Serializable] + public class SharedQuaternion : SharedObject {} + [Serializable] + public class SharedString : SharedObject {} + [Serializable] + public class SharedFloat : SharedObject {} + [Serializable] + public class SharedShader : SharedObject {} + [Serializable] + public class SharedMaterial : SharedObject {} + [Serializable] + public class SharedMesh : SharedObject {} + [Serializable] + public class SharedTransform : SharedObject {} + [Serializable] + public class SharedLayerMask : SharedObject {} + [Serializable] + public class SharedRenderer : SharedObject { } + + #region Graphic + [Serializable] + public class SharedSprite : SharedObject {} + [Serializable] + public class SharedColor : SharedObject {} + [Serializable] + public class SharedRenderTexture : SharedObject {} + [Serializable] + public class SharedTexture : SharedObject {} + #endregion + + #region GameObject + [Serializable] + public class SharedTag : SharedObject {} + [Serializable] + public class SharedLayer : SharedObject {} + [Serializable] + public class SharedStaticEditorFlags : SharedObject {} + #endregion + + #region Animator + [Serializable] + public class SharedRuntimeAnimatorController : SharedObject {} + [Serializable] + public class SharedAnimatorCullingMode : SharedObject {} + #endregion + + #region Renderer + [Serializable] + public class SharedLightProbeUsage : SharedObject {} + [Serializable] + public class SharedReflectionProbeUsage : SharedObject {} + [Serializable] + public class SharedShadowCastingMode : SharedObject {} + #endregion + + #region LODGroup + [Serializable] + public class SharedFadeMode : SharedObject {} + #endregion + + #region ReflectionProbe + [Serializable] + public class SharedReflectionProbeMode : SharedObject {} + [Serializable] + public class SharedReflectionProbeResolution : SharedObject {} + public enum ReflectionProbeResolution : int + { + _16 = 16, + _32 = 32, + _64 = 64, + _128 = 128, + _256 = 256, + _512 = 512, + _1024 = 1024, + _2048 = 2048 + } + #endregion + + #region AudioClip + [Serializable] + public class SharedAudioClip : SharedObject {} + #endregion + + #region RenderTexture + [Serializable] + public class SharedDepthBuffer : SharedObject {} + public enum DepthBuffer : int + { + _0 = 0, + _16 = 16, + _24 = 24, + _32 = 32 + } + [Serializable] + public class SharedAntiAliasing : SharedObject {} + public enum AntiAliasing : int + { + None = 1, + _2Samples = 2, + _4Samples = 4, + _8Samples = 8 + } + [Serializable] + public class SharedFilterMode : SharedObject {} + #endregion + + #region Light + [Serializable] + public class SharedLightmapBakeType : SharedObject {} + [Serializable] + public class SharedLightShadows : SharedObject {} + #endregion +} +#endif diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/EQS_Fields.cs.meta b/EasyQuestSwitch/EQS_Types/EQS_Fields.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/EQS_Fields.cs.meta rename to EasyQuestSwitch/EQS_Types/EQS_Fields.cs.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Animator.cs b/EasyQuestSwitch/EQS_Types/Type_Animator.cs similarity index 62% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Animator.cs rename to EasyQuestSwitch/EQS_Types/Type_Animator.cs index 33e4470..4c62d93 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Animator.cs +++ b/EasyQuestSwitch/EQS_Types/Type_Animator.cs @@ -1,44 +1,34 @@ -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine; -using EasyQuestSwitch.Fields; - -namespace EasyQuestSwitch.Types -{ - public class Type_Animator : Type_Behaviour - { - [System.NonSerialized] - private Animator type; - - public SharedRuntimeAnimatorController Controller = new SharedRuntimeAnimatorController(); - public SharedAnimatorCullingMode CullingMode = new SharedAnimatorCullingMode(); - - public override void Setup(Object type) - { - base.Setup(type); - Animator component = (Animator)type; - if(component.runtimeAnimatorController != null) Controller.Setup(component.runtimeAnimatorController); - CullingMode.Setup(component.cullingMode); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - base.Process(type, buildTarget); - Animator component = (Animator)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.runtimeAnimatorController = Controller.PC; - component.cullingMode = CullingMode.PC; - break; - case BuildTarget.Android: - component.runtimeAnimatorController = Controller.Quest; - component.cullingMode = CullingMode.Quest; - break; - default: - break; - } - } - } -} -#endif +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_Animator : Type_Behaviour + { + [System.NonSerialized] + private Animator type; + + public SharedRuntimeAnimatorController Controller = new SharedRuntimeAnimatorController(); + public SharedAnimatorCullingMode CullingMode = new SharedAnimatorCullingMode(); + + public override void Setup(Object type) + { + base.Setup(type); + Animator component = (Animator)type; + if(component.runtimeAnimatorController != null) Controller.Setup(component.runtimeAnimatorController); + CullingMode.Setup(component.cullingMode); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + Animator component = (Animator)type; + component.runtimeAnimatorController = Controller.Get(buildTarget); + component.cullingMode = CullingMode.Get(buildTarget); + } + } +} +#endif diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Animator.cs.meta b/EasyQuestSwitch/EQS_Types/Type_Animator.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Animator.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_Animator.cs.meta diff --git a/EasyQuestSwitch/EQS_Types/Type_AudioSource.cs b/EasyQuestSwitch/EQS_Types/Type_AudioSource.cs new file mode 100644 index 0000000..7b1f948 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_AudioSource.cs @@ -0,0 +1,32 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_AudioSource : Type_Behaviour + { + [System.NonSerialized] + private AudioSource type; + + public SharedAudioClip AudioClip = new SharedAudioClip(); + + public override void Setup(Object type) + { + base.Setup(type); + AudioSource component = (AudioSource)type; + AudioClip.Setup(component.clip); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + AudioSource component = (AudioSource)type; + component.clip = AudioClip.Get(buildTarget); + } + } +} +#endif + diff --git a/EasyQuestSwitch/EQS_Types/Type_AudioSource.cs.meta b/EasyQuestSwitch/EQS_Types/Type_AudioSource.cs.meta new file mode 100644 index 0000000..ae2909b --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_AudioSource.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 04f2bc6899d290340ab8e071f498224d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Base.cs b/EasyQuestSwitch/EQS_Types/Type_Base.cs similarity index 91% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Base.cs rename to EasyQuestSwitch/EQS_Types/Type_Base.cs index 239c089..fe3805c 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Base.cs +++ b/EasyQuestSwitch/EQS_Types/Type_Base.cs @@ -1,13 +1,14 @@ -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine; - -namespace EasyQuestSwitch.Types -{ - public abstract class Type_Base : MonoBehaviour - { - public abstract void Setup(Object type); - public abstract void Process(Object type, BuildTarget buildTarget); - } -} +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public abstract class Type_Base : MonoBehaviour + { + public abstract void Setup(Object type); + public abstract void Process(Object type, BuildTarget buildTarget); + } +} #endif \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Base.cs.meta b/EasyQuestSwitch/EQS_Types/Type_Base.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Base.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_Base.cs.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Behaviour.cs b/EasyQuestSwitch/EQS_Types/Type_Behaviour.cs similarity index 60% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Behaviour.cs rename to EasyQuestSwitch/EQS_Types/Type_Behaviour.cs index acfbb3d..27ffd21 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Behaviour.cs +++ b/EasyQuestSwitch/EQS_Types/Type_Behaviour.cs @@ -1,39 +1,30 @@ -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine; -using EasyQuestSwitch.Fields; - -namespace EasyQuestSwitch.Types -{ - public class Type_Behaviour : Type_Base - { - [System.NonSerialized] - private Behaviour type; - - public SharedBool Enabled = new SharedBool(); - - public override void Setup(Object type) - { - Behaviour component = (Behaviour)type; - Enabled.Setup(component.enabled); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - Behaviour component = (Behaviour)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.enabled = Enabled.PC; - break; - case BuildTarget.Android: - component.enabled = Enabled.Quest; - break; - default: - break; - } - } - } -} -#endif - +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_Behaviour : Type_Base + { + [System.NonSerialized] + private Behaviour type; + + public SharedBool Enabled = new SharedBool(); + + public override void Setup(Object type) + { + Behaviour component = (Behaviour)type; + Enabled.Setup(component.enabled); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + Behaviour component = (Behaviour)type; + component.enabled = Enabled.Get(buildTarget); + } + } +} +#endif + diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Behaviour.cs.meta b/EasyQuestSwitch/EQS_Types/Type_Behaviour.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Behaviour.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_Behaviour.cs.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_BoxCollider.cs b/EasyQuestSwitch/EQS_Types/Type_BoxCollider.cs similarity index 61% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_BoxCollider.cs rename to EasyQuestSwitch/EQS_Types/Type_BoxCollider.cs index 61e5f2f..71c2568 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_BoxCollider.cs +++ b/EasyQuestSwitch/EQS_Types/Type_BoxCollider.cs @@ -1,45 +1,35 @@ -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine; -using EasyQuestSwitch.Fields; - -namespace EasyQuestSwitch.Types -{ - public class Type_BoxCollider : Type_Collider - { - [System.NonSerialized] - private BoxCollider type; - - public SharedVector3 Size = new SharedVector3(); - public SharedVector3 Center = new SharedVector3(); - - public override void Setup(Object type) - { - base.Setup(type); - BoxCollider component = (BoxCollider)type; - Size.Setup(component.size); - Center.Setup(component.center); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - base.Process(type, buildTarget); - BoxCollider component = (BoxCollider)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.size = Size.PC; - component.center = Center.PC; - break; - case BuildTarget.Android: - component.size = Size.Quest; - component.center = Center.Quest; - break; - default: - break; - } - } - } -} -#endif - +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_BoxCollider : Type_Collider + { + [System.NonSerialized] + private BoxCollider type; + + public SharedVector3 Size = new SharedVector3(); + public SharedVector3 Center = new SharedVector3(); + + public override void Setup(Object type) + { + base.Setup(type); + BoxCollider component = (BoxCollider)type; + Size.Setup(component.size); + Center.Setup(component.center); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + BoxCollider component = (BoxCollider)type; + component.size = Size.Get(buildTarget); + component.center = Center.Get(buildTarget); + } + } +} +#endif + diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_BoxCollider.cs.meta b/EasyQuestSwitch/EQS_Types/Type_BoxCollider.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_BoxCollider.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_BoxCollider.cs.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Camera.cs b/EasyQuestSwitch/EQS_Types/Type_Camera.cs similarity index 58% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Camera.cs rename to EasyQuestSwitch/EQS_Types/Type_Camera.cs index fa7dcc9..03420d3 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Camera.cs +++ b/EasyQuestSwitch/EQS_Types/Type_Camera.cs @@ -1,44 +1,40 @@ -#if UNITY_EDITOR -using UnityEngine; -using EasyQuestSwitch.Fields; -using UnityEditor; - -namespace EasyQuestSwitch.Types -{ - public class Type_Camera : Type_Behaviour - { - [System.NonSerialized] - private Camera type; - - public SharedFloat ClippingPlaneNear = new SharedFloat(); - public SharedFloat ClippingPlaneFar = new SharedFloat(); - - public override void Setup(Object type) - { - base.Setup(type); - Camera component = (Camera)type; - ClippingPlaneNear.Setup(component.nearClipPlane); - ClippingPlaneFar.Setup(component.farClipPlane); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - base.Process(type, buildTarget); - Camera component = (Camera)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.nearClipPlane = ClippingPlaneNear.PC; - component.farClipPlane = ClippingPlaneFar.PC; - break; - case BuildTarget.Android: - component.nearClipPlane = ClippingPlaneNear.Quest; - component.farClipPlane = ClippingPlaneFar.Quest; - break; - default: - break; - } - } - } -} +#if UNITY_EDITOR +using UnityEngine; +using EasyQuestSwitch.Fields; +using UnityEditor; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_Camera : Type_Behaviour + { + [System.NonSerialized] + private Camera type; + + public SharedFloat ClippingPlaneNear = new SharedFloat(); + public SharedFloat ClippingPlaneFar = new SharedFloat(); + public SharedRenderTexture TargetTexture = new SharedRenderTexture(); + public SharedBool OcclusionCulling = new SharedBool(); + + public override void Setup(Object type) + { + base.Setup(type); + Camera component = (Camera)type; + ClippingPlaneNear.Setup(component.nearClipPlane); + ClippingPlaneFar.Setup(component.farClipPlane); + TargetTexture.Setup(component.targetTexture); + OcclusionCulling.Setup(component.useOcclusionCulling); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + Camera component = (Camera)type; + component.nearClipPlane = ClippingPlaneNear.Get(buildTarget); + component.farClipPlane = ClippingPlaneFar.Get(buildTarget); + component.targetTexture = TargetTexture.Get(buildTarget); + component.useOcclusionCulling = OcclusionCulling.Get(buildTarget); + } + } +} #endif \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Camera.cs.meta b/EasyQuestSwitch/EQS_Types/Type_Camera.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Camera.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_Camera.cs.meta diff --git a/EasyQuestSwitch/EQS_Types/Type_CanvasScaler.cs b/EasyQuestSwitch/EQS_Types/Type_CanvasScaler.cs new file mode 100644 index 0000000..d1d304a --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_CanvasScaler.cs @@ -0,0 +1,36 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; +using UnityEngine.UI; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_CanvasScaler : Type_Behaviour + { + [System.NonSerialized] + private CanvasScaler type; + + public SharedFloat ScaleFactor = new SharedFloat(); + public SharedFloat ReferencePixelsPerUnit = new SharedFloat(); + + public override void Setup(Object type) + { + base.Setup(type); + CanvasScaler component = (CanvasScaler)type; + ScaleFactor.Setup(component.scaleFactor); + ReferencePixelsPerUnit.Setup(component.referencePixelsPerUnit); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + CanvasScaler component = (CanvasScaler)type; + component.scaleFactor = ScaleFactor.Get(buildTarget); + component.referencePixelsPerUnit = ReferencePixelsPerUnit.Get(buildTarget); + } + } +} +#endif + diff --git a/EasyQuestSwitch/EQS_Types/Type_CanvasScaler.cs.meta b/EasyQuestSwitch/EQS_Types/Type_CanvasScaler.cs.meta new file mode 100644 index 0000000..8d099d0 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_CanvasScaler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9338ae4189f97e94091fd92050403ecf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Collider.cs b/EasyQuestSwitch/EQS_Types/Type_Collider.cs similarity index 55% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Collider.cs rename to EasyQuestSwitch/EQS_Types/Type_Collider.cs index 7b529a2..1665b20 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Collider.cs +++ b/EasyQuestSwitch/EQS_Types/Type_Collider.cs @@ -1,42 +1,32 @@ -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine; -using EasyQuestSwitch.Fields; - -namespace EasyQuestSwitch.Types -{ - public class Type_Collider : Type_Base - { - [System.NonSerialized] - private Collider type; - - public SharedBool Enabled = new SharedBool(); - public SharedBool IsTrigger = new SharedBool(); - - public override void Setup(Object type) - { - Collider component = (Collider)type; - Enabled.Setup(component.enabled); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - Collider component = (Collider)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.enabled = Enabled.PC; - component.isTrigger = IsTrigger.PC; - break; - case BuildTarget.Android: - component.enabled = Enabled.Quest; - component.isTrigger = IsTrigger.Quest; - break; - default: - break; - } - } - } -} -#endif - +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_Collider : Type_Base + { + [System.NonSerialized] + private Collider type; + + public SharedBool Enabled = new SharedBool(); + public SharedBool IsTrigger = new SharedBool(); + + public override void Setup(Object type) + { + Collider component = (Collider)type; + Enabled.Setup(component.enabled); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + Collider component = (Collider)type; + component.enabled = Enabled.Get(buildTarget); + component.isTrigger = IsTrigger.Get(buildTarget); + } + } +} +#endif + diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Collider.cs.meta b/EasyQuestSwitch/EQS_Types/Type_Collider.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Collider.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_Collider.cs.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_GameObject.cs b/EasyQuestSwitch/EQS_Types/Type_GameObject.cs similarity index 55% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_GameObject.cs rename to EasyQuestSwitch/EQS_Types/Type_GameObject.cs index d9dcae2..157a7c0 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_GameObject.cs +++ b/EasyQuestSwitch/EQS_Types/Type_GameObject.cs @@ -1,51 +1,39 @@ -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine; -using EasyQuestSwitch.Fields; - -namespace EasyQuestSwitch.Types -{ - public class Type_GameObject : Type_Base - { - [System.NonSerialized] - private GameObject type; - - public SharedBool Active = new SharedBool(); - public SharedTag Tag = new SharedTag(); - public SharedLayer Layer = new SharedLayer(); - public SharedStaticEditorFlags StaticEditorFlags = new SharedStaticEditorFlags(); - - public override void Setup(Object type) - { - GameObject component = (GameObject)type; - Active.Setup(component.activeInHierarchy); - Tag.Setup(component.tag); - Layer.Setup(component.layer); - StaticEditorFlags.Setup(GameObjectUtility.GetStaticEditorFlags(component)); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - GameObject component = (GameObject)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.SetActive(Active.PC); - component.tag = Tag.PC; - component.layer = Layer.PC; - GameObjectUtility.SetStaticEditorFlags(component, StaticEditorFlags.PC); - break; - case BuildTarget.Android: - component.SetActive(Active.Quest); - component.tag = Tag.Quest; - component.layer = Layer.Quest; - GameObjectUtility.SetStaticEditorFlags(component, StaticEditorFlags.Quest); - break; - default: - break; - } - } - } -} -#endif - +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_GameObject : Type_Base + { + [System.NonSerialized] + private GameObject type; + + public SharedBool Active = new SharedBool(); + public SharedTag Tag = new SharedTag(); + public SharedLayer Layer = new SharedLayer(); + public SharedStaticEditorFlags StaticEditorFlags = new SharedStaticEditorFlags(); + + public override void Setup(Object type) + { + GameObject component = (GameObject)type; + Active.Setup(component.activeInHierarchy); + Tag.Setup(component.tag); + Layer.Setup(component.layer); + StaticEditorFlags.Setup(GameObjectUtility.GetStaticEditorFlags(component)); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + GameObject component = (GameObject)type; + component.SetActive(Active.Get(buildTarget)); + component.tag = Tag.Get(buildTarget); + component.layer = Layer.Get(buildTarget); + GameObjectUtility.SetStaticEditorFlags(component, StaticEditorFlags.Get(buildTarget)); + } + } +} +#endif + diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_GameObject.cs.meta b/EasyQuestSwitch/EQS_Types/Type_GameObject.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_GameObject.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_GameObject.cs.meta diff --git a/EasyQuestSwitch/EQS_Types/Type_Image.cs b/EasyQuestSwitch/EQS_Types/Type_Image.cs new file mode 100644 index 0000000..a1bb9a5 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_Image.cs @@ -0,0 +1,39 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; +using UnityEngine.UI; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_Image : Type_Behaviour + { + [System.NonSerialized] + private Image type; + + public SharedSprite Sprite = new SharedSprite(); + public SharedColor Color = new SharedColor(); + public SharedMaterial Material = new SharedMaterial(); + + public override void Setup(Object type) + { + base.Setup(type); + Image component = (Image)type; + Sprite.Setup(component.sprite); + Color.Setup(component.color); + Material.Setup(component.material); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + Image component = (Image)type; + component.sprite = Sprite.Get(buildTarget); + component.color = Color.Get(buildTarget); + component.material = Material.Get(buildTarget); + } + } +} +#endif + diff --git a/EasyQuestSwitch/EQS_Types/Type_Image.cs.meta b/EasyQuestSwitch/EQS_Types/Type_Image.cs.meta new file mode 100644 index 0000000..e3eb2f6 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_Image.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 219eb80d4e193a3418678aabec87e169 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EasyQuestSwitch/EQS_Types/Type_LODGroup.cs b/EasyQuestSwitch/EQS_Types/Type_LODGroup.cs new file mode 100644 index 0000000..ac72644 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_LODGroup.cs @@ -0,0 +1,56 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; +using UnityEngine.UI; +using System.Collections.Generic; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_LODGroup : Type_Base + { + [System.NonSerialized] + private LODGroup type; + + public SharedBool Enabled = new SharedBool(); + public SharedFadeMode FadeMode = new SharedFadeMode(); + public SharedBool AnimateCrossFading = new SharedBool(); + public List Percentage = new List(); + public List FadeTransitionWidth = new List(); + + public override void Setup(Object type) + { + LODGroup component = (LODGroup)type; + Enabled.Setup(component.enabled); + FadeMode.Setup(component.fadeMode); + AnimateCrossFading.Setup(component.animateCrossFading); + LOD[] lods = component.GetLODs(); + Debug.Log(lods.Length); + for(int i = 0; i < lods.Length; i++) + { + Percentage.Add(new SharedFloat()); + Percentage[i].Setup(lods[i].screenRelativeTransitionHeight * 100); + FadeTransitionWidth.Add(new SharedFloat()); + FadeTransitionWidth[i].Setup(lods[i].fadeTransitionWidth); + } + } + + public override void Process(Object type, BuildTarget buildTarget) + { + LODGroup component = (LODGroup)type; + LOD[] lods = component.GetLODs(); + component.enabled = Enabled.Get(buildTarget); + component.fadeMode = FadeMode.Get(buildTarget); + component.animateCrossFading = AnimateCrossFading.Get(buildTarget); + for (int i = 0; i < lods.Length; i++) + { + lods[i].screenRelativeTransitionHeight = Percentage[i].Get(buildTarget) / 100; + lods[i].fadeTransitionWidth = FadeTransitionWidth[i].Get(buildTarget); + } + component.SetLODs(lods); + } + } +} +#endif + diff --git a/EasyQuestSwitch/EQS_Types/Type_LODGroup.cs.meta b/EasyQuestSwitch/EQS_Types/Type_LODGroup.cs.meta new file mode 100644 index 0000000..ab21075 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_LODGroup.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cb71919926eb63544adce19a87fdffe4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EasyQuestSwitch/EQS_Types/Type_Light.cs b/EasyQuestSwitch/EQS_Types/Type_Light.cs new file mode 100644 index 0000000..2a56658 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_Light.cs @@ -0,0 +1,43 @@ +#if UNITY_EDITOR +using UnityEngine; +using EasyQuestSwitch.Fields; +using UnityEditor; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_Light : Type_Behaviour + { + [System.NonSerialized] + private Light type; + + public SharedColor Color = new SharedColor(); + public SharedLightmapBakeType Mode = new SharedLightmapBakeType(); + public SharedFloat Intensity = new SharedFloat(); + public SharedFloat IndirectMultiplier = new SharedFloat(); + public SharedLightShadows ShadowType = new SharedLightShadows(); + + public override void Setup(Object type) + { + base.Setup(type); + Light component = (Light)type; + Color.Setup(component.color); + Mode.Setup(component.lightmapBakeType); + Intensity.Setup(component.intensity); + IndirectMultiplier.Setup(component.bounceIntensity); + ShadowType.Setup(component.shadows); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + Light component = (Light)type; + component.color = Color.Get(buildTarget); + component.lightmapBakeType = Mode.Get(buildTarget); + component.intensity = Intensity.Get(buildTarget); + component.bounceIntensity = IndirectMultiplier.Get(buildTarget); + component.shadows = ShadowType.Get(buildTarget); + } + } +} +#endif \ No newline at end of file diff --git a/EasyQuestSwitch/EQS_Types/Type_Light.cs.meta b/EasyQuestSwitch/EQS_Types/Type_Light.cs.meta new file mode 100644 index 0000000..073d62f --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_Light.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 015e2a1364babf8418393e8afc9b3eb7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EasyQuestSwitch/EQS_Types/Type_Material.cs b/EasyQuestSwitch/EQS_Types/Type_Material.cs new file mode 100644 index 0000000..9050081 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_Material.cs @@ -0,0 +1,61 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_Material : Type_Base + { + [System.NonSerialized] + private Material type; + + public SharedShader Shader = new SharedShader(); + private SharedString ShaderPath = new SharedString(); + + public override void Setup(Object type) + { + Material material = (Material)type; + Shader.Setup(material.shader); + ShaderPath.Setup(material.shader.name); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + Material material = (Material)type; + if(Shader.Get(buildTarget) != null) + { + switch (buildTarget) + { + case BuildTarget.StandaloneWindows: + ShaderPath.PC = Shader.Get(buildTarget).name; + break; + case BuildTarget.Android: + ShaderPath.Quest = Shader.Get(buildTarget).name; + break; + } + } + else if(Shader.Get(buildTarget) == null && !string.IsNullOrEmpty(ShaderPath.Get(buildTarget))) + { + switch(buildTarget) + { + case BuildTarget.StandaloneWindows: + Shader.PC = UnityEngine.Shader.Find(ShaderPath.PC); + break; + case BuildTarget.Android: + Shader.Quest = UnityEngine.Shader.Find(ShaderPath.Quest); + break; + } + } + + if(Shader.Get(buildTarget) == null) + { + throw new MissingReferenceException(); + } + material.shader = Shader.Get(buildTarget); + } + } +} +#endif + diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Material.cs.meta b/EasyQuestSwitch/EQS_Types/Type_Material.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Material.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_Material.cs.meta diff --git a/EasyQuestSwitch/EQS_Types/Type_MeshCollider.cs b/EasyQuestSwitch/EQS_Types/Type_MeshCollider.cs new file mode 100644 index 0000000..b5ec019 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_MeshCollider.cs @@ -0,0 +1,36 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_MeshCollider : Type_Collider + { + [System.NonSerialized] + private MeshCollider type; + + public SharedBool Convex = new SharedBool(); + public SharedMesh SharedMesh = new SharedMesh(); + + public override void Setup(Object type) + { + base.Setup(type); + MeshCollider component = (MeshCollider)type; + Convex.Setup(component.convex); + SharedMesh.Setup(component.sharedMesh); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + MeshCollider component = (MeshCollider)type; + component.enabled = Enabled.Get(buildTarget); + component.isTrigger = IsTrigger.Get(buildTarget) && Convex.Get(buildTarget) ? true : false; + component.convex = Convex.Get(buildTarget); + component.sharedMesh = SharedMesh.Get(buildTarget); + } + } +} +#endif + diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_MeshCollider.cs.meta b/EasyQuestSwitch/EQS_Types/Type_MeshCollider.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_MeshCollider.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_MeshCollider.cs.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_MeshFilter.cs b/EasyQuestSwitch/EQS_Types/Type_MeshFilter.cs similarity index 60% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_MeshFilter.cs rename to EasyQuestSwitch/EQS_Types/Type_MeshFilter.cs index 1e3eefd..9818525 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_MeshFilter.cs +++ b/EasyQuestSwitch/EQS_Types/Type_MeshFilter.cs @@ -1,39 +1,30 @@ -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine; -using EasyQuestSwitch.Fields; - -namespace EasyQuestSwitch.Types -{ - public class Type_MeshFilter : Type_Base - { - [System.NonSerialized] - private MeshFilter type; - - public SharedMesh Mesh = new SharedMesh(); - - public override void Setup(Object type) - { - MeshFilter component = (MeshFilter)type; - Mesh.Setup(component.sharedMesh); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - MeshFilter component = (MeshFilter)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.sharedMesh = Mesh.PC; - break; - case BuildTarget.Android: - component.sharedMesh = Mesh.Quest; - break; - default: - break; - } - } - } -} -#endif - +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_MeshFilter : Type_Base + { + [System.NonSerialized] + private MeshFilter type; + + public SharedMesh Mesh = new SharedMesh(); + + public override void Setup(Object type) + { + MeshFilter component = (MeshFilter)type; + Mesh.Setup(component.sharedMesh); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + MeshFilter component = (MeshFilter)type; + component.sharedMesh = Mesh.Get(buildTarget); + } + } +} +#endif + diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_MeshFilter.cs.meta b/EasyQuestSwitch/EQS_Types/Type_MeshFilter.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_MeshFilter.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_MeshFilter.cs.meta diff --git a/EasyQuestSwitch/EQS_Types/Type_RawImage.cs b/EasyQuestSwitch/EQS_Types/Type_RawImage.cs new file mode 100644 index 0000000..28db36b --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_RawImage.cs @@ -0,0 +1,39 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; +using UnityEngine.UI; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_RawImage : Type_Behaviour + { + [System.NonSerialized] + private RawImage type; + + public SharedTexture Texture = new SharedTexture(); + public SharedColor Color = new SharedColor(); + public SharedMaterial Material = new SharedMaterial(); + + public override void Setup(Object type) + { + base.Setup(type); + RawImage component = (RawImage)type; + Texture.Setup(component.texture); + Color.Setup(component.color); + Material.Setup(component.material); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + RawImage component = (RawImage)type; + component.texture = Texture.Get(buildTarget); + component.color = Color.Get(buildTarget); + component.material = Material.Get(buildTarget); + } + } +} +#endif + diff --git a/EasyQuestSwitch/EQS_Types/Type_RawImage.cs.meta b/EasyQuestSwitch/EQS_Types/Type_RawImage.cs.meta new file mode 100644 index 0000000..af90c2a --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_RawImage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 29c79e5574ae6bf4ab53f230552607f4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EasyQuestSwitch/EQS_Types/Type_ReflectionProbe.cs b/EasyQuestSwitch/EQS_Types/Type_ReflectionProbe.cs new file mode 100644 index 0000000..52fd29a --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_ReflectionProbe.cs @@ -0,0 +1,48 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; +using UnityEngine.UI; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_ReflectionProbe : Type_Behaviour + { + [System.NonSerialized] + private ReflectionProbe type; + + public SharedReflectionProbeMode ReflectionProbeType = new SharedReflectionProbeMode(); + public SharedTexture Cubemap = new SharedTexture(); + public SharedInt Importance = new SharedInt(); + public SharedFloat Intensity = new SharedFloat(); + public SharedBool BoxProjection = new SharedBool(); + public SharedReflectionProbeResolution Resolution = new SharedReflectionProbeResolution(); + + public override void Setup(Object type) + { + base.Setup(type); + ReflectionProbe component = (ReflectionProbe)type; + ReflectionProbeType.Setup(component.mode); + Cubemap.Setup(component.customBakedTexture); + Importance.Setup(component.importance); + Intensity.Setup(component.intensity); + BoxProjection.Setup(component.boxProjection); + Resolution.Setup((ReflectionProbeResolution)component.resolution); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + ReflectionProbe component = (ReflectionProbe)type; + component.mode = ReflectionProbeType.Get(buildTarget); + component.customBakedTexture = Cubemap.Get(buildTarget); + component.importance = Importance.Get(buildTarget); + component.intensity = Intensity.Get(buildTarget); + component.boxProjection = BoxProjection.Get(buildTarget); + component.resolution = (int)Resolution.Get(buildTarget); + } + } +} +#endif + diff --git a/EasyQuestSwitch/EQS_Types/Type_ReflectionProbe.cs.meta b/EasyQuestSwitch/EQS_Types/Type_ReflectionProbe.cs.meta new file mode 100644 index 0000000..6d64cba --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_ReflectionProbe.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f00c16f621dc31b4a9cbce512ad67048 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EasyQuestSwitch/EQS_Types/Type_RenderTexture.cs b/EasyQuestSwitch/EQS_Types/Type_RenderTexture.cs new file mode 100644 index 0000000..2f044f1 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_RenderTexture.cs @@ -0,0 +1,45 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; +using UnityEngine.Experimental.Rendering; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_RenderTexture : Type_Base + { + [System.NonSerialized] + private RenderTexture type; + + public SharedVector2Int Size = new SharedVector2Int(); + public SharedAntiAliasing AntiAliasing = new SharedAntiAliasing(); + public SharedDepthBuffer DepthBuffer = new SharedDepthBuffer(); + public SharedBool EnableMipMaps = new SharedBool(); + public SharedFilterMode FilterMode = new SharedFilterMode(); + + public override void Setup(Object type) + { + RenderTexture component = (RenderTexture)type; + Size.Setup(new Vector2Int(component.width, component.height)); + AntiAliasing.Setup((AntiAliasing)component.antiAliasing); + DepthBuffer.Setup((DepthBuffer)component.depth); + EnableMipMaps.Setup(component.useMipMap); + FilterMode.Setup(component.filterMode); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + RenderTexture component = (RenderTexture)type; + component.Release(); + component.width = Size.Get(buildTarget).x; + component.height = Size.Get(buildTarget).y; + component.antiAliasing = (int)AntiAliasing.Get(buildTarget); + component.depth = (int)DepthBuffer.Get(buildTarget); + component.useMipMap = EnableMipMaps.Get(buildTarget); + component.filterMode = FilterMode.Get(buildTarget); + } + } +} +#endif + diff --git a/EasyQuestSwitch/EQS_Types/Type_RenderTexture.cs.meta b/EasyQuestSwitch/EQS_Types/Type_RenderTexture.cs.meta new file mode 100644 index 0000000..34e7e81 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_RenderTexture.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bbd716eb592f7cd4a8a9e8c881ef8848 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Renderer.cs b/EasyQuestSwitch/EQS_Types/Type_Renderer.cs similarity index 51% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Renderer.cs rename to EasyQuestSwitch/EQS_Types/Type_Renderer.cs index 5af009a..2095e92 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Renderer.cs +++ b/EasyQuestSwitch/EQS_Types/Type_Renderer.cs @@ -1,80 +1,61 @@ -#if UNITY_EDITOR -using System.Collections.Generic; -using System.Linq; -using UnityEditor; -using UnityEngine; -using EasyQuestSwitch.Fields; - -namespace EasyQuestSwitch.Types -{ - public class Type_Renderer : Type_Base - { - [System.NonSerialized] - private Renderer type; - - public SharedBool Enabled = new SharedBool(); - public SharedLightProbeUsage LightProbes = new SharedLightProbeUsage(); - public SharedTransform AnchorOverride = new SharedTransform(); - public SharedReflectionProbeUsage ReflectionProbes = new SharedReflectionProbeUsage(); - public SharedShadowCastingMode CastShadows = new SharedShadowCastingMode(); - public SharedBool ReceiveShadows = new SharedBool(); - public SharedBool DynamicOccluded = new SharedBool(); - public List Materials = new List(); - - public override void Setup(Object type) - { - Renderer component = (Renderer)type; - Enabled.Setup(component.enabled); - LightProbes.Setup(component.lightProbeUsage); - AnchorOverride.Setup(component.probeAnchor); - ReflectionProbes.Setup(component.reflectionProbeUsage); - CastShadows.Setup(component.shadowCastingMode); - ReceiveShadows.Setup(component.receiveShadows); - DynamicOccluded.Setup(component.allowOcclusionWhenDynamic); - for (int i = 0; i < component.sharedMaterials.Length; i++) - { - Materials.Add(new SharedMaterial()); - Materials[i].Setup(component.sharedMaterials[i]); - } - } - - public override void Process(Object type, BuildTarget buildTarget) - { - - Renderer component = (Renderer)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.enabled = Enabled.PC; - component.lightProbeUsage = LightProbes.PC; - component.probeAnchor = AnchorOverride.PC; - component.reflectionProbeUsage = ReflectionProbes.PC; - component.shadowCastingMode = CastShadows.PC; - component.receiveShadows = ReceiveShadows.PC; - component.allowOcclusionWhenDynamic = DynamicOccluded.PC; - for (int i = 0; i < component.sharedMaterials.Length; i++) - { - component.sharedMaterials = Materials.Select(x => x.PC).ToArray(); - } - break; - case BuildTarget.Android: - component.enabled = Enabled.Quest; - component.lightProbeUsage = LightProbes.Quest; - component.probeAnchor = AnchorOverride.Quest; - component.reflectionProbeUsage = ReflectionProbes.Quest; - component.shadowCastingMode = CastShadows.Quest; - component.receiveShadows = ReceiveShadows.Quest; - component.allowOcclusionWhenDynamic = DynamicOccluded.Quest; - for (int i = 0; i < component.sharedMaterials.Length; i++) - { - component.sharedMaterials = Materials.Select(x => x.Quest).ToArray(); - } - break; - default: - break; - } - } - } -} -#endif - +#if UNITY_EDITOR +using System.Collections.Generic; +using System.Linq; +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_Renderer : Type_Base + { + [System.NonSerialized] + private Renderer type; + + public SharedBool Enabled = new SharedBool(); + public SharedLightProbeUsage LightProbes = new SharedLightProbeUsage(); + public SharedTransform AnchorOverride = new SharedTransform(); + public SharedReflectionProbeUsage ReflectionProbes = new SharedReflectionProbeUsage(); + public SharedShadowCastingMode CastShadows = new SharedShadowCastingMode(); + public SharedBool ReceiveShadows = new SharedBool(); + public SharedBool DynamicOccluded = new SharedBool(); + public List Materials = new List(); + + public override void Setup(Object type) + { + Renderer component = (Renderer)type; + Enabled.Setup(component.enabled); + LightProbes.Setup(component.lightProbeUsage); + AnchorOverride.Setup(component.probeAnchor); + ReflectionProbes.Setup(component.reflectionProbeUsage); + CastShadows.Setup(component.shadowCastingMode); + ReceiveShadows.Setup(component.receiveShadows); + DynamicOccluded.Setup(component.allowOcclusionWhenDynamic); + for (int i = 0; i < component.sharedMaterials.Length; i++) + { + Materials.Add(new SharedMaterial()); + Materials[i].Setup(component.sharedMaterials[i]); + } + } + + public override void Process(Object type, BuildTarget buildTarget) + { + + Renderer component = (Renderer)type; + component.enabled = Enabled.Get(buildTarget); + component.lightProbeUsage = LightProbes.Get(buildTarget); + component.probeAnchor = AnchorOverride.Get(buildTarget); + component.reflectionProbeUsage = ReflectionProbes.Get(buildTarget); + component.shadowCastingMode = CastShadows.Get(buildTarget); + component.receiveShadows = ReceiveShadows.Get(buildTarget); + component.allowOcclusionWhenDynamic = DynamicOccluded.Get(buildTarget); + for (int i = 0; i < component.sharedMaterials.Length; i++) + { + component.sharedMaterials = Materials.Select(x => x.Get(buildTarget)).ToArray(); + } + } + } +} +#endif + diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Renderer.cs.meta b/EasyQuestSwitch/EQS_Types/Type_Renderer.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Renderer.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_Renderer.cs.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_SkinnedMeshRenderer.cs b/EasyQuestSwitch/EQS_Types/Type_SkinnedMeshRenderer.cs similarity index 61% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_SkinnedMeshRenderer.cs rename to EasyQuestSwitch/EQS_Types/Type_SkinnedMeshRenderer.cs index aca7d2e..28f998b 100644 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_SkinnedMeshRenderer.cs +++ b/EasyQuestSwitch/EQS_Types/Type_SkinnedMeshRenderer.cs @@ -1,45 +1,35 @@ -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine; -using EasyQuestSwitch.Fields; - -namespace EasyQuestSwitch.Types -{ - public class Type_SkinnedMeshRenderer : Type_Renderer - { - [System.NonSerialized] - private SkinnedMeshRenderer type; - - public SharedMesh Mesh = new SharedMesh(); - public SharedBool UpdateWhenOffscreen = new SharedBool(); - - public override void Setup(Object type) - { - base.Setup(type); - SkinnedMeshRenderer component = (SkinnedMeshRenderer)type; - Mesh.Setup(component.sharedMesh); - UpdateWhenOffscreen.Setup(component.updateWhenOffscreen); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - base.Process(type, buildTarget); - SkinnedMeshRenderer component = (SkinnedMeshRenderer)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.sharedMesh = Mesh.PC; - component.updateWhenOffscreen = UpdateWhenOffscreen.PC; - break; - case BuildTarget.Android: - component.sharedMesh = Mesh.Quest; - component.updateWhenOffscreen = UpdateWhenOffscreen.Quest; - break; - default: - break; - } - } - } -} -#endif - +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_SkinnedMeshRenderer : Type_Renderer + { + [System.NonSerialized] + private SkinnedMeshRenderer type; + + public SharedMesh Mesh = new SharedMesh(); + public SharedBool UpdateWhenOffscreen = new SharedBool(); + + public override void Setup(Object type) + { + base.Setup(type); + SkinnedMeshRenderer component = (SkinnedMeshRenderer)type; + Mesh.Setup(component.sharedMesh); + UpdateWhenOffscreen.Setup(component.updateWhenOffscreen); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + SkinnedMeshRenderer component = (SkinnedMeshRenderer)type; + component.sharedMesh = Mesh.Get(buildTarget); + component.updateWhenOffscreen = UpdateWhenOffscreen.Get(buildTarget); + } + } +} +#endif + diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_SkinnedMeshRenderer.cs.meta b/EasyQuestSwitch/EQS_Types/Type_SkinnedMeshRenderer.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_SkinnedMeshRenderer.cs.meta rename to EasyQuestSwitch/EQS_Types/Type_SkinnedMeshRenderer.cs.meta diff --git a/EasyQuestSwitch/EQS_Types/Type_SphereCollider.cs b/EasyQuestSwitch/EQS_Types/Type_SphereCollider.cs new file mode 100644 index 0000000..66ad2cf --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_SphereCollider.cs @@ -0,0 +1,35 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_SphereCollider : Type_Collider + { + [System.NonSerialized] + private SphereCollider type; + + public SharedVector3 Center = new SharedVector3(); + public SharedFloat Radius = new SharedFloat(); + + public override void Setup(Object type) + { + base.Setup(type); + SphereCollider component = (SphereCollider)type; + Center.Setup(component.center); + Radius.Setup(component.radius); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + SphereCollider component = (SphereCollider)type; + component.center = Center.Get(buildTarget); + component.radius = Radius.Get(buildTarget); + } + } +} +#endif + diff --git a/EasyQuestSwitch/EQS_Types/Type_SphereCollider.cs.meta b/EasyQuestSwitch/EQS_Types/Type_SphereCollider.cs.meta new file mode 100644 index 0000000..1f65014 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_SphereCollider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 232f2729806dde74cb9d60676f8a668a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EasyQuestSwitch/EQS_Types/Type_SpriteRenderer.cs b/EasyQuestSwitch/EQS_Types/Type_SpriteRenderer.cs new file mode 100644 index 0000000..e681e1b --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_SpriteRenderer.cs @@ -0,0 +1,36 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_SpriteRenderer : Type_Base + { + [System.NonSerialized] + private SpriteRenderer type; + + public SharedSprite Sprite = new SharedSprite(); + public SharedColor Color = new SharedColor(); + public SharedMaterial Material = new SharedMaterial(); + + public override void Setup(Object type) + { + SpriteRenderer component = (SpriteRenderer)type; + Sprite.Setup(component.sprite); + Color.Setup(component.color); + Material.Setup(component.material); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + SpriteRenderer component = (SpriteRenderer)type; + component.sprite = Sprite.Get(buildTarget); + component.color = Color.Get(buildTarget); + component.material = Material.Get(buildTarget); + } + } +} +#endif + diff --git a/EasyQuestSwitch/EQS_Types/Type_SpriteRenderer.cs.meta b/EasyQuestSwitch/EQS_Types/Type_SpriteRenderer.cs.meta new file mode 100644 index 0000000..b40bc40 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_SpriteRenderer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 19d26f7760d81ad4ba699aef7d2a4d4c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EasyQuestSwitch/EQS_Types/Type_Transform.cs b/EasyQuestSwitch/EQS_Types/Type_Transform.cs new file mode 100644 index 0000000..a52f187 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_Transform.cs @@ -0,0 +1,36 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_Transform : Type_Base + { + [System.NonSerialized] + private Transform type; + + public SharedVector3 Position = new SharedVector3(); + public SharedVector3 Rotation = new SharedVector3(); + public SharedVector3 Scale = new SharedVector3(); + + public override void Setup(Object type) + { + Transform component = (Transform)type; + Position.Setup(component.position); + Rotation.Setup(component.localEulerAngles); + Scale.Setup(component.localScale); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + Transform component = (Transform)type; + component.position = Position.Get(buildTarget); + component.localEulerAngles = Rotation.Get(buildTarget); + component.localScale = Scale.Get(buildTarget); + } + } +} +#endif + diff --git a/EasyQuestSwitch/EQS_Types/Type_Transform.cs.meta b/EasyQuestSwitch/EQS_Types/Type_Transform.cs.meta new file mode 100644 index 0000000..a296552 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/Type_Transform.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fbd49075aeb7a9542a1dc0a205dbf0e3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/VRC.meta b/EasyQuestSwitch/EQS_Types/VRC.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/VRC.meta rename to EasyQuestSwitch/EQS_Types/VRC.meta diff --git a/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK2.cs b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK2.cs new file mode 100644 index 0000000..d82fb2a --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK2.cs @@ -0,0 +1,38 @@ +#if UNITY_EDITOR && VRC_SDK_VRCSDK2 +using UnityEditor; +using UnityEngine; +using VRCSDK2; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_VRC_MirrorReflection : Type_Behaviour + { + [System.NonSerialized] + private VRC_MirrorReflection type; + + public SharedBool DisablePixelLights = new SharedBool(); + public SharedBool TurnOffMirrorOcclusion = new SharedBool(); + public SharedLayerMask ReflectLayers = new SharedLayerMask(); + + public override void Setup(Object type) + { + base.Setup(type); + VRC_MirrorReflection component = (VRC_MirrorReflection)type; + DisablePixelLights.Setup(component.m_DisablePixelLights); + TurnOffMirrorOcclusion.Setup(component.TurnOffMirrorOcclusion); + ReflectLayers.Setup(component.m_ReflectLayers); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + VRC_MirrorReflection component = (VRC_MirrorReflection)type; + component.m_DisablePixelLights = DisablePixelLights.Get(buildTarget); + component.TurnOffMirrorOcclusion = TurnOffMirrorOcclusion.Get(buildTarget); + component.m_ReflectLayers = ReflectLayers.Get(buildTarget); + } + } +} +#endif diff --git a/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK2.cs.meta b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK2.cs.meta new file mode 100644 index 0000000..97abe81 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 685b3567e0fa848499c74f0a2c0641e5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK3.cs b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK3.cs new file mode 100644 index 0000000..0e44ea6 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK3.cs @@ -0,0 +1,38 @@ +#if UNITY_EDITOR && VRC_SDK_VRCSDK3 +using UnityEditor; +using UnityEngine; +using VRC.SDK3.Components; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_VRC_MirrorReflection : Type_Behaviour + { + [System.NonSerialized] + private VRCMirrorReflection type; + + public SharedBool DisablePixelLights = new SharedBool(); + public SharedBool TurnOffMirrorOcclusion = new SharedBool(); + public SharedLayerMask ReflectLayers = new SharedLayerMask(); + + public override void Setup(Object type) + { + base.Setup(type); + VRCMirrorReflection component = (VRCMirrorReflection)type; + DisablePixelLights.Setup(component.m_DisablePixelLights); + TurnOffMirrorOcclusion.Setup(component.TurnOffMirrorOcclusion); + ReflectLayers.Setup(component.m_ReflectLayers); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + base.Process(type, buildTarget); + VRCMirrorReflection component = (VRCMirrorReflection)type; + component.m_DisablePixelLights = DisablePixelLights.Get(buildTarget); + component.TurnOffMirrorOcclusion = TurnOffMirrorOcclusion.Get(buildTarget); + component.m_ReflectLayers = ReflectLayers.Get(buildTarget); + } + } +} +#endif diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection.cs.meta b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK3.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection.cs.meta rename to EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection_SDK3.cs.meta diff --git a/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK2.cs b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK2.cs new file mode 100644 index 0000000..5e1901c --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK2.cs @@ -0,0 +1,42 @@ +#if UNITY_EDITOR && VRC_SDK_VRCSDK2 +using UnityEditor; +using UnityEngine; +using VRCSDK2; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_VRC_SpatialAudioSource : Type_Base + { + [System.NonSerialized] + private VRC_SpatialAudioSource type; + + public SharedFloat Gain = new SharedFloat(); + public SharedFloat Far = new SharedFloat(); + public SharedFloat Near = new SharedFloat(); + public SharedFloat VolumetricRadius = new SharedFloat(); + public SharedBool EnableSpatialization = new SharedBool(); + + public override void Setup(Object type) + { + VRC_SpatialAudioSource component = (VRC_SpatialAudioSource)type; + Gain.Setup(component.Gain); + Far.Setup(component.Far); + Near.Setup(component.Near); + VolumetricRadius.Setup(component.VolumetricRadius); + EnableSpatialization.Setup(component.EnableSpatialization); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + VRC_SpatialAudioSource component = (VRC_SpatialAudioSource)type; + component.Gain = Gain.Get(buildTarget); + component.Far = Far.Get(buildTarget); + component.Near = Near.Get(buildTarget); + component.VolumetricRadius = VolumetricRadius.Get(buildTarget); + component.EnableSpatialization = EnableSpatialization.Get(buildTarget); + } + } +} +#endif diff --git a/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK2.cs.meta b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK2.cs.meta new file mode 100644 index 0000000..8160e59 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1f23792d33ca2e245beec9499bf5289f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK3.cs b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK3.cs new file mode 100644 index 0000000..ea9d234 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK3.cs @@ -0,0 +1,42 @@ +#if UNITY_EDITOR && VRC_SDK_VRCSDK3 +using UnityEditor; +using UnityEngine; +using VRC.SDK3.Components; +using EasyQuestSwitch.Fields; + +namespace EasyQuestSwitch.Types +{ + [AddComponentMenu("")] + public class Type_VRC_SpatialAudioSource : Type_Base + { + [System.NonSerialized] + private VRCSpatialAudioSource type; + + public SharedFloat Gain = new SharedFloat(); + public SharedFloat Far = new SharedFloat(); + public SharedFloat Near = new SharedFloat(); + public SharedFloat VolumetricRadius = new SharedFloat(); + public SharedBool EnableSpatialization = new SharedBool(); + + public override void Setup(Object type) + { + VRCSpatialAudioSource component = (VRCSpatialAudioSource)type; + Gain.Setup(component.Gain); + Far.Setup(component.Far); + Near.Setup(component.Near); + VolumetricRadius.Setup(component.VolumetricRadius); + EnableSpatialization.Setup(component.EnableSpatialization); + } + + public override void Process(Object type, BuildTarget buildTarget) + { + VRCSpatialAudioSource component = (VRCSpatialAudioSource)type; + component.Gain = Gain.Get(buildTarget); + component.Far = Far.Get(buildTarget); + component.Near = Near.Get(buildTarget); + component.VolumetricRadius = VolumetricRadius.Get(buildTarget); + component.EnableSpatialization = EnableSpatialization.Get(buildTarget); + } + } +} +#endif diff --git a/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK3.cs.meta b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK3.cs.meta new file mode 100644 index 0000000..098fc42 --- /dev/null +++ b/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_SpatialAudioSource_SDK3.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 64470d2381aa00740a79721986236e51 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/VRCPrefabs/EasyQuestSwitch/Editor.meta b/EasyQuestSwitch/Editor.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/Editor.meta rename to EasyQuestSwitch/Editor.meta diff --git a/VRCPrefabs/EasyQuestSwitch/Editor/EQS_PropertyDrawers.cs b/EasyQuestSwitch/Editor/EQS_PropertyDrawers.cs similarity index 80% rename from VRCPrefabs/EasyQuestSwitch/Editor/EQS_PropertyDrawers.cs rename to EasyQuestSwitch/Editor/EQS_PropertyDrawers.cs index 9cb0580..70aaafc 100644 --- a/VRCPrefabs/EasyQuestSwitch/Editor/EQS_PropertyDrawers.cs +++ b/EasyQuestSwitch/Editor/EQS_PropertyDrawers.cs @@ -1,159 +1,191 @@ -#if UNITY_EDITOR -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using EasyQuestSwitch.Types; -using UnityEditorInternal; - -namespace EasyQuestSwitch.Fields -{ - - public class BaseDrawer : PropertyDrawer - { - protected float labelRatio = 0.25f; - protected float optionRatio = 0.735f/2; - protected float dividerRatio = 0.02f; - - protected Rect labelRect; - protected Rect optionARect; - protected Rect dividerRect; - protected Rect optionBRect; - - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - { - position.height = EditorGUIUtility.singleLineHeight; - labelRect = GetRatioedRect(position, labelRatio); - optionARect = GetRatioedRect(position, optionRatio); - dividerRect = GetRatioedRect(position, dividerRatio); - optionARect.x += labelRect.width; - dividerRect.x += labelRect.width + optionARect.width; - optionBRect = optionARect; - optionBRect.x += optionARect.width + dividerRect.width; - dividerRect.x += dividerRect.width / 2; - dividerRect.width = 1; - } - - public override float GetPropertyHeight(SerializedProperty property, GUIContent label) - { - return EditorGUIUtility.singleLineHeight; - } - - public Rect GetRatioedRect(Rect currentRect, float ratio) - { - Rect newRect = currentRect; - newRect.width = currentRect.width * ratio; - return newRect; - } - } - - public class PlatformLabel : BaseDrawer - { - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - { - base.OnGUI(position, property, label); - - EditorGUI.LabelField(optionARect, "PC"); - EditorGUI.DrawRect(dividerRect, Color.grey); - EditorGUI.LabelField(optionBRect, "Quest"); - } - } - - [CustomPropertyDrawer(typeof(SharedBool), false) - , CustomPropertyDrawer(typeof(SharedInt), false) - , CustomPropertyDrawer(typeof(SharedFloat), false) - , CustomPropertyDrawer(typeof(SharedVector3), false) - , CustomPropertyDrawer(typeof(SharedString), false) - , CustomPropertyDrawer(typeof(SharedTransform), false) - , CustomPropertyDrawer(typeof(SharedMesh), false) - , CustomPropertyDrawer(typeof(SharedMaterial), false) - , CustomPropertyDrawer(typeof(SharedShader), false) - , CustomPropertyDrawer(typeof(SharedRuntimeAnimatorController), false) - , CustomPropertyDrawer(typeof(SharedAnimatorCullingMode), false) - , CustomPropertyDrawer(typeof(SharedLightProbeUsage), false) - , CustomPropertyDrawer(typeof(SharedReflectionProbeUsage), false) - , CustomPropertyDrawer(typeof(SharedShadowCastingMode), false) - , CustomPropertyDrawer(typeof(SharedLayerMask), false)] - public class PropertiesDrawer : BaseDrawer - { - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - { - base.OnGUI(position, property, label); - - EditorGUI.BeginProperty(position, label, property); - - SerializedProperty PC = property.FindPropertyRelative("PC"); - SerializedProperty Quest = property.FindPropertyRelative("Quest"); - - EditorGUI.PrefixLabel(labelRect, GUIUtility.GetControlID(FocusType.Passive), label); - EditorGUI.PropertyField(optionARect, PC, GUIContent.none); - EditorGUI.DrawRect(dividerRect, Color.grey); - EditorGUI.PropertyField(optionBRect, Quest, GUIContent.none); - EditorGUI.EndProperty(); - } - } - - [CustomPropertyDrawer(typeof(SharedTag), false)] - public class TagDrawer : BaseDrawer - { - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - { - base.OnGUI(position, property, label); - - EditorGUI.BeginProperty(position, label, property); - - SerializedProperty PC = property.FindPropertyRelative("PC"); - SerializedProperty Quest = property.FindPropertyRelative("Quest"); - - EditorGUI.PrefixLabel(labelRect, GUIUtility.GetControlID(FocusType.Passive), label); - PC.stringValue = EditorGUI.TagField(optionARect, PC.stringValue); - EditorGUI.DrawRect(dividerRect, Color.grey); - Quest.stringValue = EditorGUI.TagField(optionBRect, Quest.stringValue); - EditorGUI.EndProperty(); - } - } - - [CustomPropertyDrawer(typeof(SharedLayer), false)] - public class LayerDrawer : BaseDrawer - { - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - { - base.OnGUI(position, property, label); - - EditorGUI.BeginProperty(position, label, property); - - SerializedProperty PC = property.FindPropertyRelative("PC"); - SerializedProperty Quest = property.FindPropertyRelative("Quest"); - - EditorGUI.PrefixLabel(labelRect, GUIUtility.GetControlID(FocusType.Passive), label); - PC.intValue = EditorGUI.LayerField(optionARect, PC.intValue); - EditorGUI.DrawRect(dividerRect, Color.grey); - Quest.intValue = EditorGUI.LayerField(optionBRect, Quest.intValue); - EditorGUI.EndProperty(); - } - } - - [CustomPropertyDrawer(typeof(SharedStaticEditorFlags), false)] - public class MaskField : BaseDrawer - { - public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) - { - base.OnGUI(position, property, label); - - EditorGUI.BeginProperty(position, label, property); - - SerializedProperty PC = property.FindPropertyRelative("PC"); - SerializedProperty Quest = property.FindPropertyRelative("Quest"); - - EditorGUI.PrefixLabel(labelRect, GUIUtility.GetControlID(FocusType.Passive), label); - PC.intValue = EditorGUI.MaskField(optionARect, PC.intValue, PC.enumDisplayNames); - EditorGUI.DrawRect(dividerRect, Color.grey); - Quest.intValue = EditorGUI.MaskField(optionBRect, Quest.intValue, Quest.enumDisplayNames); - EditorGUI.EndProperty(); - } - } - -} - - +#if UNITY_EDITOR +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using EasyQuestSwitch.Types; +using UnityEditorInternal; + +namespace EasyQuestSwitch.Fields +{ + + public class BaseDrawer : PropertyDrawer + { + protected float labelRatio = 0.25f; + protected float optionRatio = 0.735f/2; + protected float dividerRatio = 0.02f; + + protected Rect labelRect; + protected Rect optionARect; + protected Rect dividerRect; + protected Rect optionBRect; + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + position.height = EditorGUIUtility.singleLineHeight; + labelRect = GetRatioedRect(position, labelRatio); + optionARect = GetRatioedRect(position, optionRatio); + dividerRect = GetRatioedRect(position, dividerRatio); + optionARect.x += labelRect.width; + dividerRect.x += labelRect.width + optionARect.width; + optionBRect = optionARect; + optionBRect.x += optionARect.width + dividerRect.width; + dividerRect.x += dividerRect.width / 2; + dividerRect.width = 1; + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + return EditorGUIUtility.singleLineHeight; + } + + public Rect GetRatioedRect(Rect currentRect, float ratio) + { + Rect newRect = currentRect; + newRect.width = currentRect.width * ratio; + return newRect; + } + } + + public class PlatformLabel : BaseDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + base.OnGUI(position, property, label); + + EditorGUI.LabelField(optionARect, "PC"); + EditorGUI.DrawRect(dividerRect, Color.grey); + EditorGUI.LabelField(optionBRect, "Quest"); + } + } + + [CustomPropertyDrawer(typeof(SharedBool), false) + , CustomPropertyDrawer(typeof(SharedInt), false) + , CustomPropertyDrawer(typeof(SharedFloat), false) + , CustomPropertyDrawer(typeof(SharedVector2), false) + , CustomPropertyDrawer(typeof(SharedVector2Int), false) + , CustomPropertyDrawer(typeof(SharedVector3), false) + , CustomPropertyDrawer(typeof(SharedVector3Int), false) + , CustomPropertyDrawer(typeof(SharedVector4), false) + , CustomPropertyDrawer(typeof(SharedQuaternion), false) + , CustomPropertyDrawer(typeof(SharedString), false) + , CustomPropertyDrawer(typeof(SharedTransform), false) + , CustomPropertyDrawer(typeof(SharedMesh), false) + , CustomPropertyDrawer(typeof(SharedMaterial), false) + , CustomPropertyDrawer(typeof(SharedShader), false) + , CustomPropertyDrawer(typeof(SharedLayerMask), false) + , CustomPropertyDrawer(typeof(SharedRenderer), true) + // Graphic + , CustomPropertyDrawer(typeof(SharedSprite), false) + , CustomPropertyDrawer(typeof(SharedColor), false) + , CustomPropertyDrawer(typeof(SharedRenderTexture), false) + , CustomPropertyDrawer(typeof(SharedTexture), false) + // Animator + , CustomPropertyDrawer(typeof(SharedRuntimeAnimatorController), false) + , CustomPropertyDrawer(typeof(SharedAnimatorCullingMode), false) + // Renderer + , CustomPropertyDrawer(typeof(SharedLightProbeUsage), false) + , CustomPropertyDrawer(typeof(SharedReflectionProbeUsage), false) + , CustomPropertyDrawer(typeof(SharedShadowCastingMode), false) + // LODGroup + , CustomPropertyDrawer(typeof(SharedFadeMode), false) + // Reflection Probe + , CustomPropertyDrawer(typeof(SharedReflectionProbeMode), false) + , CustomPropertyDrawer(typeof(SharedReflectionProbeResolution), false) + // AudioClip + , CustomPropertyDrawer(typeof(SharedAudioClip), false) + // RenderTexture + , CustomPropertyDrawer(typeof(SharedDepthBuffer), false) + , CustomPropertyDrawer(typeof(SharedAntiAliasing), false) + , CustomPropertyDrawer(typeof(SharedFilterMode), false) + // Light + , CustomPropertyDrawer(typeof(SharedLightmapBakeType), false) + , CustomPropertyDrawer(typeof(SharedLightShadows), false)] + public class PropertiesDrawer : BaseDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + base.OnGUI(position, property, label); + + EditorGUI.BeginProperty(position, label, property); + + SerializedProperty PC = property.FindPropertyRelative("PC"); + SerializedProperty Quest = property.FindPropertyRelative("Quest"); + + EditorGUI.PrefixLabel(labelRect, GUIUtility.GetControlID(FocusType.Passive), label); + EditorGUI.PropertyField(optionARect, PC, GUIContent.none); + EditorGUI.DrawRect(dividerRect, Color.grey); + EditorGUI.PropertyField(optionBRect, Quest, GUIContent.none); + EditorGUI.EndProperty(); + } + } + + // GameObject + [CustomPropertyDrawer(typeof(SharedTag), false)] + public class TagDrawer : BaseDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + base.OnGUI(position, property, label); + + EditorGUI.BeginProperty(position, label, property); + + SerializedProperty PC = property.FindPropertyRelative("PC"); + SerializedProperty Quest = property.FindPropertyRelative("Quest"); + + EditorGUI.PrefixLabel(labelRect, GUIUtility.GetControlID(FocusType.Passive), label); + PC.stringValue = EditorGUI.TagField(optionARect, PC.stringValue); + EditorGUI.DrawRect(dividerRect, Color.grey); + Quest.stringValue = EditorGUI.TagField(optionBRect, Quest.stringValue); + EditorGUI.EndProperty(); + } + } + + // GameObject + [CustomPropertyDrawer(typeof(SharedLayer), false)] + public class LayerDrawer : BaseDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + base.OnGUI(position, property, label); + + EditorGUI.BeginProperty(position, label, property); + + SerializedProperty PC = property.FindPropertyRelative("PC"); + SerializedProperty Quest = property.FindPropertyRelative("Quest"); + + EditorGUI.PrefixLabel(labelRect, GUIUtility.GetControlID(FocusType.Passive), label); + PC.intValue = EditorGUI.LayerField(optionARect, PC.intValue); + EditorGUI.DrawRect(dividerRect, Color.grey); + Quest.intValue = EditorGUI.LayerField(optionBRect, Quest.intValue); + EditorGUI.EndProperty(); + } + } + + // GameObject + [CustomPropertyDrawer(typeof(SharedStaticEditorFlags), false)] + public class MaskFieldDrawer : BaseDrawer + { + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + base.OnGUI(position, property, label); + + EditorGUI.BeginProperty(position, label, property); + + SerializedProperty PC = property.FindPropertyRelative("PC"); + SerializedProperty Quest = property.FindPropertyRelative("Quest"); + + EditorGUI.PrefixLabel(labelRect, GUIUtility.GetControlID(FocusType.Passive), label); + PC.intValue = EditorGUI.MaskField(optionARect, PC.intValue, PC.enumDisplayNames); + EditorGUI.DrawRect(dividerRect, Color.grey); + Quest.intValue = EditorGUI.MaskField(optionBRect, Quest.intValue, Quest.enumDisplayNames); + EditorGUI.EndProperty(); + } + } + + + +} + + #endif \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/Editor/EQS_PropertyDrawers.cs.meta b/EasyQuestSwitch/Editor/EQS_PropertyDrawers.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/Editor/EQS_PropertyDrawers.cs.meta rename to EasyQuestSwitch/Editor/EQS_PropertyDrawers.cs.meta diff --git a/EasyQuestSwitch/Editor/EQS_Window.cs b/EasyQuestSwitch/Editor/EQS_Window.cs new file mode 100644 index 0000000..63121b4 --- /dev/null +++ b/EasyQuestSwitch/Editor/EQS_Window.cs @@ -0,0 +1,584 @@ +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 + { + + [MenuItem("Window/Easy Quest Switch")] + public static void ShowWindow() + { + GetWindow(typeof(EQS_Window), false, "Easy Quest Switch"); + } + + private SerializedObject serializedObject; + private SerializedProperty eqsData; + private ReorderableList reorderableList; + + private EQS_Data _data; + private EQS_Data data { + get { + if (_data == null) _data = GameObject.Find("EQS_DATA")?.GetComponent(); + return _data; + } + set { + _data = value; + } + } + + private Vector2 scrollPos; + + private Texture2D logo; + [SerializeField] + private Texture2D headerBG; + + private bool settingsMenu; + private int chosenLanguage; + private int chosenListFormat; + private bool revealEQSdata = false; + + private void CreatePlatformDependantHeader(BuildTarget buildTarget) + { + headerBG = new Texture2D(1, 1); + switch (buildTarget) + { + case BuildTarget.StandaloneWindows64: + headerBG.SetPixel(0, 0, new Color(0.15f, 0.5f, 0.75f)); + break; + case BuildTarget.Android: + headerBG.SetPixel(0, 0, new Color(0, 0.8f, 0.3f)); + break; + default: + headerBG.SetPixel(0, 0, new Color(0.75f, 0.15f, 0.2f)); + break; + } + headerBG.Apply(); + } + + private void OnEnable() + { + serializedObject = null; + EditorSceneManager.activeSceneChangedInEditMode += OnSceneChanged; + Undo.undoRedoPerformed += OnUndoRedo; + + minSize = new Vector2(512, 320); + CreatePlatformDependantHeader(EditorUserBuildSettings.activeBuildTarget); + logo = (Texture2D)Resources.Load("EQS_Logo", typeof(Texture2D)); + + EQS_Localization.LoadLanguages(); + chosenLanguage = EditorPrefs.GetInt("EQS_Language", 0); + EQS_Localization.SetLanguage(chosenLanguage); + chosenListFormat = EditorPrefs.GetInt("EQS_ListFormat", 0); // 0 - Simple, 1 - Reorderable + + if (data != null) + { + SetupEQS(); + revealEQSdata = data.gameObject.hideFlags == HideFlags.HideInHierarchy ? false : true; + } + } + + private void CreateEQS() + { + GameObject sceneRefGO = new GameObject("EQS_DATA"); + EQS_Data sceneRef = sceneRefGO.AddComponent(); + sceneRefGO.tag = "EditorOnly"; + sceneRefGO.hideFlags = HideFlags.HideInHierarchy; + data = sceneRef; + SetupEQS(); + } + + private void RevealEQSData() { if(data != null) data.gameObject.hideFlags = HideFlags.None; } + private void HideEQSData() + { + if (data != null) + { + data.gameObject.hideFlags = HideFlags.HideInHierarchy; + EditorApplication.DirtyHierarchyWindowSorting(); + } + } + + private void SetupEQS() + { + serializedObject = new SerializedObject(data); + eqsData = serializedObject.FindProperty("Objects"); + + if(chosenListFormat == 0) // Simple + { + if (reorderableList != null) + { + UnregisterReorderableListCallbacks(); + reorderableList = null; + } + } + else if (chosenListFormat == 1) // Reorderable + { + reorderableList = new ReorderableList(serializedObject, eqsData, true, false, false, false); + RegisterReorderableListCallbacks(); + reorderableList.showDefaultBackground = false; + reorderableList.headerHeight = 0; + } + } + + private void RegisterReorderableListCallbacks() + { + reorderableList.drawElementCallback += DrawElementCallback; + reorderableList.elementHeightCallback += ElementHeightCallback; + reorderableList.drawElementBackgroundCallback += DrawElementBackgroundCallback; + reorderableList.onMouseDragCallback += OnMouseDragCallback; + } + + private void UnregisterReorderableListCallbacks() + { + reorderableList.drawElementCallback -= DrawElementCallback; + reorderableList.elementHeightCallback -= ElementHeightCallback; + reorderableList.drawElementBackgroundCallback -= DrawElementBackgroundCallback; + reorderableList.onMouseDragCallback -= OnMouseDragCallback; + } + + private void DestroyEQS() + { + serializedObject = null; + DestroyImmediate(data.gameObject); + _data = data = null; + } + + private void OnUndoRedo() => Repaint(); + + private void OnSceneChanged(Scene current, Scene next) => OnEnable(); + + #region ReorderableList callbacks + + private void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused) + { + rect.width = EditorGUIUtility.currentViewWidth - GUI.skin.verticalScrollbar.fixedWidth - 32; + float oldY = rect.y; + rect.y += EditorGUIUtility.standardVerticalSpacing * 2; + + SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(index); + SerializedProperty elementTarget = element.FindPropertyRelative("Target"); + EditorGUI.BeginChangeCheck(); + EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width + 4, EditorGUIUtility.singleLineHeight), elementTarget, GUIContent.none); + if(EditorGUI.EndChangeCheck()) + { + serializedObject.ApplyModifiedProperties(); + data.ValidateData(index); + } + + UnityEngine.Object elementTypeObj = element.FindPropertyRelative("Type").objectReferenceValue; + if (elementTypeObj != null) + { + // Create foldout + SerializedProperty showFoldout = element.FindPropertyRelative("Foldout"); + rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing * 4; + showFoldout.boolValue = EditorGUI.Foldout(new Rect(rect.x, rect.y, EditorGUIUtility.currentViewWidth - GUI.skin.verticalScrollbar.fixedWidth, EditorGUIUtility.singleLineHeight), showFoldout.boolValue, ""); + if (showFoldout.boolValue) + { + PlatformLabel platformLabel = new PlatformLabel(); + platformLabel.OnGUI(rect, null, null); + + SerializedObject elementType = new SerializedObject(elementTypeObj); + SerializedProperty elementTypeIterator = elementType.GetIterator(); + elementTypeIterator.NextVisible(true); + while (elementTypeIterator.NextVisible(false)) + { + elementTypeIterator.serializedObject.Update(); + rect.y += EditorGUI.GetPropertyHeight(elementTypeIterator, false) * 1.5f; + EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), elementTypeIterator, true); + if (elementTypeIterator.isArray && elementTypeIterator.isExpanded && elementTypeIterator.arraySize != 0) + { + for (int i = 0; i < elementTypeIterator.arraySize; i++) + { + rect.y += EditorGUI.GetPropertyHeight(elementTypeIterator.GetArrayElementAtIndex(i), true) * 1.5f; + } + } + elementTypeIterator.serializedObject.ApplyModifiedProperties(); + } + } + } + + rect.x = 0; + rect.y = oldY + ElementHeightCallback(index) - EditorGUIUtility.standardVerticalSpacing; + rect.width = EditorGUIUtility.currentViewWidth; + rect.height = 1; + EditorGUI.DrawRect(rect, Color.grey); + } + + private float ElementHeightCallback(int index) + { + SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(index); + float propertyHeight = EditorGUI.GetPropertyHeight(element, false); // true = include children + float nestedHeight = 0.0f; + if(element.FindPropertyRelative("Foldout").boolValue) + { + UnityEngine.Object elementTypeObj = element.FindPropertyRelative("Type").objectReferenceValue; + if(elementTypeObj != null) + { + SerializedObject elementType = new SerializedObject(elementTypeObj); + SerializedProperty elementTypeIterator = elementType.GetIterator(); + bool enableChildren = true; + while (elementTypeIterator.NextVisible(enableChildren)) + { + if (elementTypeIterator.isExpanded && elementTypeIterator.isArray && elementTypeIterator.arraySize != 0) + { + nestedHeight += EditorGUI.GetPropertyHeight(elementTypeIterator, false) * 1.5f; + for (int i = 0; i < elementTypeIterator.arraySize; i++) + { + nestedHeight += EditorGUI.GetPropertyHeight(elementTypeIterator.GetArrayElementAtIndex(i), true) * 1.5f; + } + } + else + { + nestedHeight += EditorGUI.GetPropertyHeight(elementTypeIterator, true) * 1.5f; + } + enableChildren = false; + } + } + } + else + { + nestedHeight += EditorGUIUtility.singleLineHeight; + } + float spacing = EditorGUIUtility.singleLineHeight; + return propertyHeight + nestedHeight + spacing; + } + + private void DrawElementBackgroundCallback(Rect rect, int index, bool isActive, bool isFocused) + { + if(reorderableList.count > 0) + { + if (reorderableList.serializedProperty != null) + { + Rect newRect = new Rect(rect); + newRect.height = EditorGUI.GetPropertyHeight(reorderableList.serializedProperty.GetArrayElementAtIndex(index), false) * 2f + EditorGUIUtility.singleLineHeight; + EditorGUI.DrawRect(newRect, new Color(0, 0, 0, 0.15f)); + } + } + ReorderableList.defaultBehaviours.DrawElementBackground(rect, index, isActive, isFocused, reorderableList.draggable); + } + + private void OnMouseDragCallback(ReorderableList list) + { + SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(list.index); + SerializedProperty showFoldout = element.FindPropertyRelative("Foldout"); + if (showFoldout.boolValue) showFoldout.boolValue = false; + } + #endregion + + private void OnAddCallback(SerializedProperty list) + { + int index = list.arraySize; + list.arraySize++; + SerializedProperty element = list.GetArrayElementAtIndex(index); + element.FindPropertyRelative("Target").objectReferenceValue = null; + element.FindPropertyRelative("Type").objectReferenceValue = null; + element.FindPropertyRelative("Foldout").boolValue = false; + } + + private void OnRemoveCallback(ReorderableList list) + { + if (list.count == 0) return; + SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(list.index); + element.FindPropertyRelative("Target").objectReferenceValue = null; + UnityEngine.Object elementObj = element.FindPropertyRelative("Type").objectReferenceValue; + if (elementObj != null) DestroyImmediate(elementObj); + ReorderableList.defaultBehaviours.DoRemoveButton(reorderableList); + } + + private void OnRemoveCallback(SerializedProperty list, int index) + { + if (list.arraySize == 0) return; + SerializedProperty element = list.GetArrayElementAtIndex(index); + element.FindPropertyRelative("Target").objectReferenceValue = null; + UnityEngine.Object elementObj = element.FindPropertyRelative("Type").objectReferenceValue; + if (elementObj != null) DestroyImmediate(elementObj); + list.DeleteArrayElementAtIndex(index); + } + + private void OnGUI() + { + if(serializedObject != null) serializedObject.Update(); + + // Header + GUIStyle headerStyle = new GUIStyle("Box"); + using (new GUILayout.HorizontalScope(headerStyle)) + { + headerStyle.normal.background = headerBG; + using (new GUILayout.HorizontalScope(headerStyle)) + { + GUILayout.FlexibleSpace(); + Color guiBackgroundColor = GUI.backgroundColor; + GUI.backgroundColor = new Color(1,1,1,0); + GUILayout.Box(logo, GUILayout.Width(150), GUILayout.Height(70)); + GUI.backgroundColor = guiBackgroundColor; + GUILayout.FlexibleSpace(); + Rect settingsRect = GUILayoutUtility.GetLastRect(); + settingsRect.width /= 2; + settingsRect.x += settingsRect.width; + settingsRect.height = EditorGUIUtility.singleLineHeight + 2; + settingsMenu = GUI.Toggle(settingsRect, settingsMenu, EQS_Localization.Current.SettingsButton, new GUIStyle("Button")); + } + } + + if(settingsMenu) + { +#if UNITY_2019_4_OR_NEWER + if (EditorSettings.assetPipelineMode != AssetPipelineMode.Version2) + { + + using (new GUILayout.HorizontalScope()) + { + GUIContent helpBoxContent = new GUIContent(EQS_Localization.Current.SettingsAssetPipelineV2, EditorGUIUtility.IconContent("console.warnicon").image); + GUIContent helpBoxButton = new GUIContent(EQS_Localization.Current.SettingsCacheButton); + float width = GUI.skin.button.CalcSize(helpBoxButton).x - 11; + float height = EditorStyles.helpBox.CalcHeight(helpBoxContent, EditorGUIUtility.currentViewWidth - width); + GUILayout.Box(helpBoxContent, EditorStyles.helpBox); + if (GUILayout.Button(helpBoxButton, GUILayout.Height(height))) SettingsService.OpenProjectSettings("Project/Editor"); + } + } +#else + if (EditorPrefs.GetInt("CacheServerMode") == 2) // CacheServerMode 2 = Disabled (not local or remote) + { + using (new GUILayout.HorizontalScope()) + { + GUIContent helpBoxContent = new GUIContent(EQS_Localization.Current.SettingsCacheWarning, EditorGUIUtility.IconContent("console.warnicon").image); + GUIContent helpBoxButton = new GUIContent(EQS_Localization.Current.SettingsCacheButton); + float width = GUI.skin.button.CalcSize(helpBoxButton).x - 11; + float height = EditorStyles.helpBox.CalcHeight(helpBoxContent, EditorGUIUtility.currentViewWidth - width); + GUILayout.Box(helpBoxContent, EditorStyles.helpBox); + if (GUILayout.Button(helpBoxButton, GUILayout.Height(height))) SettingsService.OpenUserPreferences("Preferences/Cache Server"); + } + } +#endif + + using (new GUILayout.HorizontalScope()) + { + GUILayout.Label(new GUIContent(EQS_Localization.Current.SettingsLanguage)); + using(var changeLanguage = new EditorGUI.ChangeCheckScope()) + { + chosenLanguage = EditorGUILayout.Popup(chosenLanguage, EQS_Localization.GetLanguages()); + if(changeLanguage.changed) + { + EQS_Localization.SetLanguage(chosenLanguage); + EditorPrefs.SetInt("EQS_Language", chosenLanguage); + } + } + + GUILayout.Label(new GUIContent(EQS_Localization.Current.SettingsListFormat)); + using (var changeListFormat = new EditorGUI.ChangeCheckScope()) + { + chosenListFormat = EditorGUILayout.Popup(chosenListFormat, EQS_Localization.Current.SettingsListFormatArray); + if (changeListFormat.changed) + { + SetupEQS(); + EditorPrefs.SetInt("EQS_ListFormat", chosenListFormat); + } + } + } + + using (new EditorGUI.DisabledGroupScope(serializedObject == null)) + { + using (new GUILayout.HorizontalScope()) + { + if (GUILayout.Button(EQS_Localization.Current.SettingsApplyPC)) data.CheckTarget(BuildTarget.StandaloneWindows64); + if (GUILayout.Button(EQS_Localization.Current.SettingsApplyQuest)) data.CheckTarget(BuildTarget.Android); + } + if (GUILayout.Button(EQS_Localization.Current.SettingsRemoveEQS, GUILayout.Height(32))) + { + if (EditorUtility.DisplayDialog(string.Empty, EQS_Localization.Current.PopupDeleteWarning, EQS_Localization.Current.PopupAccept, EQS_Localization.Current.PopupDecline)) + { + DestroyEQS(); + } + } + } + + using (new GUILayout.VerticalScope()) + { + GUILayout.Box(EQS_Localization.Current.SettingsExplanation, EditorStyles.wordWrappedLabel); + GUILayout.FlexibleSpace(); + using (new EditorGUI.DisabledGroupScope(serializedObject == null)) + { + using (new GUILayout.HorizontalScope(EditorStyles.helpBox)) + { + GUILayout.FlexibleSpace(); + GUIContent helpBoxContent = new GUIContent(EQS_Localization.Current.SettingsDebugOptions, EditorGUIUtility.IconContent("console.warnicon").image); + GUILayout.Box(helpBoxContent, EditorStyles.miniLabel); + GUILayout.FlexibleSpace(); + using(new GUILayout.VerticalScope()) + { + using (var toggle = new EditorGUI.ChangeCheckScope()) + { + revealEQSdata = GUILayout.Toggle(revealEQSdata, EQS_Localization.Current.SettingsDebugReveal); + if(toggle.changed) + { + if (revealEQSdata) + { + RevealEQSData(); + } + else + { + HideEQSData(); + } + } + } + } + GUILayout.FlexibleSpace(); + } + } + using (new GUILayout.HorizontalScope()) + { + GUILayout.Box(EQS_Localization.Current.SettingsFeedback, EditorStyles.wordWrappedLabel); + if (GUILayout.Button(EQS_Localization.Current.SettingsTwitter)) Application.OpenURL("https://twitter.com/JordoVR"); + if (GUILayout.Button(EQS_Localization.Current.SettingsGithub)) Application.OpenURL("https://github.com/JordoVR/EasyQuestSwitch"); + } + GUILayout.Space(EditorGUIUtility.singleLineHeight); + } + + } + else + { + if(data == null) + { + if(GUILayout.Button(EQS_Localization.Current.ListSetupEQS)) CreateEQS(); + } + else + { + // List header + using (new GUILayout.HorizontalScope()) + { + if (GUILayout.Toggle(false, EQS_Localization.Current.ListExpand, EditorStyles.toolbarButton)) + { + for (int i = 0; i < eqsData.arraySize; i++) + { + SerializedProperty element = eqsData.GetArrayElementAtIndex(i); + if (element.FindPropertyRelative("Type").objectReferenceValue != null) element.FindPropertyRelative("Foldout").boolValue = true; + } + Repaint(); + } + if (GUILayout.Toggle(false, EQS_Localization.Current.ListFold, EditorStyles.toolbarButton)) + { + for (int i = 0; i < eqsData.arraySize; i++) + { + SerializedProperty element = eqsData.GetArrayElementAtIndex(i); + element.FindPropertyRelative("Foldout").boolValue = false; + } + Repaint(); + } + if (GUILayout.Button("+", EditorStyles.toolbarButton)) + { + if (chosenListFormat == 0) // Simple + { + OnAddCallback(eqsData); + } + else if (chosenListFormat == 1) // Reorderable + { + OnAddCallback(reorderableList.serializedProperty); + reorderableList.index++; + } + scrollPos = new Vector2(0,Mathf.Infinity); + } + if (chosenListFormat == 1) // Reorderable + { + if (GUILayout.Button("-", EditorStyles.toolbarButton)) + { + OnRemoveCallback(reorderableList); + } + } + } + + // Begin scroll & list + using (var scrollView = new GUILayout.ScrollViewScope(scrollPos, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, GUI.skin.scrollView)) + { + scrollPos = scrollView.scrollPosition; + + if (chosenListFormat == 0) // Simple + { + for (int index = 0; index < eqsData.arraySize; index++) + { + SerializedProperty element = eqsData.GetArrayElementAtIndex(index); + SerializedProperty elementTarget = element.FindPropertyRelative("Target"); + + + using (new GUILayout.HorizontalScope()) + { + if (GUILayout.Button("\u2005\u2006▲", EditorStyles.toolbarButton, GUILayout.Width(24))) + { + if (index == 0) break; + eqsData.MoveArrayElement(index, index - 1); + } + if (GUILayout.Button("\u2005\u2006▼", EditorStyles.toolbarButton, GUILayout.Width(24))) + { + if (index == eqsData.arraySize) break; + eqsData.MoveArrayElement(index, index + 1); + } + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(elementTarget, new GUIContent()); + if (EditorGUI.EndChangeCheck()) + { + serializedObject.ApplyModifiedProperties(); + data.ValidateData(index); + } + if (GUILayout.Button("\u2005\u2006-", EditorStyles.toolbarButton, GUILayout.Width(24))) + { + OnRemoveCallback(eqsData, index); + continue; + } + } + // Color the background + Rect newRect = new Rect(GUILayoutUtility.GetLastRect()); + float boxHeight = newRect.height += 20; + EditorGUI.DrawRect(newRect, new Color(0, 0, 0, 0.15f)); + + UnityEngine.Object elementTypeObj = element.FindPropertyRelative("Type").objectReferenceValue; + if (elementTypeObj != null) + { + // Create foldout + SerializedProperty showFoldout = element.FindPropertyRelative("Foldout"); + showFoldout.boolValue = EditorGUILayout.Foldout(showFoldout.boolValue, ""); + + if (showFoldout.boolValue) + { + PlatformLabel platformLabel = new PlatformLabel(); + platformLabel.OnGUI(GUILayoutUtility.GetLastRect(), null, null); + + SerializedObject elementType = new SerializedObject(elementTypeObj); + SerializedProperty elementTypeIterator = elementType.GetIterator(); + elementTypeIterator.NextVisible(true); + + while (elementTypeIterator.NextVisible(false)) + { + elementTypeIterator.serializedObject.Update(); + EditorGUILayout.PropertyField(elementTypeIterator, true); + elementTypeIterator.serializedObject.ApplyModifiedProperties(); + boxHeight += EditorGUI.GetPropertyHeight(elementTypeIterator) + EditorGUIUtility.standardVerticalSpacing; + } + } + } + else + { + GUILayout.Space(boxHeight); + } + + newRect.y += boxHeight - 1; + newRect.height = 1; + EditorGUI.DrawRect(newRect, Color.grey); + } + } + else if (chosenListFormat == 1) // Reorderable + { + reorderableList.DoLayoutList(); + } + } + } + } + if(serializedObject != null) serializedObject.ApplyModifiedProperties(); + } + } +} \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/Editor/EQS_Window.cs.meta b/EasyQuestSwitch/Editor/EQS_Window.cs.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/Editor/EQS_Window.cs.meta rename to EasyQuestSwitch/Editor/EQS_Window.cs.meta diff --git a/LICENSE b/EasyQuestSwitch/LICENSE similarity index 99% rename from LICENSE rename to EasyQuestSwitch/LICENSE index 0be1716..8d794b8 100644 --- a/LICENSE +++ b/EasyQuestSwitch/LICENSE @@ -29,4 +29,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/LICENSE.meta b/EasyQuestSwitch/LICENSE.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/LICENSE.meta rename to EasyQuestSwitch/LICENSE.meta diff --git a/VRCPrefabs/EasyQuestSwitch/Resources.meta b/EasyQuestSwitch/Resources.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/Resources.meta rename to EasyQuestSwitch/Resources.meta diff --git a/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local.meta b/EasyQuestSwitch/Resources/EQS_Localizations.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local.meta rename to EasyQuestSwitch/Resources/EQS_Localizations.meta diff --git a/EasyQuestSwitch/Resources/EQS_Localizations/en.json b/EasyQuestSwitch/Resources/EQS_Localizations/en.json new file mode 100644 index 0000000..167ad75 --- /dev/null +++ b/EasyQuestSwitch/Resources/EQS_Localizations/en.json @@ -0,0 +1,36 @@ +{ + "DisplayName": "English", + + "SettingsButton": "Settings", + "SettingsLanguage": "Language", + "SettingsListFormat": "List format", + "SettingsListFormatArray": [ "Simple (faster)", "Reorderable (slower)" ], + "SettingsApplyPC": "Force apply PC settings", + "SettingsApplyQuest": "Force apply Quest settings", + "SettingsRemoveEQS": "Remove Easy Quest Switch from the scene", + "SettingsCacheWarning": "Your cache server is not enabled, you may experience long switching times! It is best to set it to local or remote. (Remote requires additional steps)", + "SettingsCacheButton": "Open settings", + "SettingsAssetPipelineV2": "You are not using Asset Pipeline v2, switching to it may give you faster platform switching times.", + "SettingsExplanation": "Welcome to Easy Quest Switch! To begin with, add a new element to the list with '+' and drag a component from the scene into the object field, several options related to that component will appear, you can configure each for the PC or Quest version of the scene respectively.\nThese options will be automatically applied to the scene when you change the Unity project build target.", + "SettingsDebugOptions": "Debug options", + "SettingsDebugReveal": "Reveal EQS_Data GameObject", + "SettingsFeedback": "If you have any issues with the program, do not hesitate to look up the github code or contact me on twitter!", + "SettingsGithub": "Github", + "SettingsTwitter": "Twitter", + + "PopupDeleteWarning": "This will delete EasyQuestSwitch from the scene and all its data, are you sure?", + "PopupTargetChanged": "Your build target has changed since the last time you've opened this scene, apply EQS changes for {0}?\nThis can be done manually in the settings menu.", + "PopupAccept": "Yes", + "PopupDecline": "No", + + "ListSetupEQS": "Setup Easy Quest Switch in the scene", + "ListExpand": "Expand all", + "ListFold": "Fold all", + + "LogUnsupportedComponent": "This is an unsupported component.", + "LogComponentExists": "This component is already present within EQS.", + "LogSwitchMissing": "Entry {0} target component is missing or not assigned.", + "LogSwitchFailure": "Entry {0} ({1}) encountered an error during the switching process: {2}.", + "LogSwitchSuccess": "EasyQuestSwitch applied the scene changes of build target {0}.", + "LogSwitchUnsupported": "Switched to an unsupported build target." +} \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local/en.json.meta b/EasyQuestSwitch/Resources/EQS_Localizations/en.json.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local/en.json.meta rename to EasyQuestSwitch/Resources/EQS_Localizations/en.json.meta diff --git a/EasyQuestSwitch/Resources/EQS_Localizations/jp.json b/EasyQuestSwitch/Resources/EQS_Localizations/jp.json new file mode 100644 index 0000000..609c90a --- /dev/null +++ b/EasyQuestSwitch/Resources/EQS_Localizations/jp.json @@ -0,0 +1,36 @@ +{ + "DisplayName": "日本語", + + "SettingsButton": "設定", + "SettingsLanguage": "言語", + "SettingsListFormat": "UIの形式", + "SettingsListFormatArray": [ "簡易 (高速)", "順番変更可能 (低速)" ], + "SettingsApplyPC": "PCの設定を強制的に適用", + "SettingsApplyQuest": "Questの設定を強制的に適用", + "SettingsRemoveEQS": "「EasyQuestSwitch」をSceneから削除", + "SettingsCacheWarning": "キャッシュサーバーが有効になっていない場合、切り替え時間が長くなる可能性があります。\nLocalかRemoteに設定するのがおすすめです。\n(Remoteの場合は追加の手順が必要です)", + "SettingsCacheButton": "設定を開く", + "SettingsAssetPipelineV2": "Asset Pipeline v2を使用していないので、これに切り替えるとプラットフォームの切り替え時間が短縮されるかもしれません。", + "SettingsExplanation": "ようこそ、「EasyQuestSwitch」へ、まずリストに機能を使いたいGameObjectを「+」で追加し\nシーンの中から任意のコンポーネントを設定欄にドラッグ&ドロップします。\nすると、そのコンポーネントに関連するオプションが表示されますので、\nSceneのPCバージョンとQuestバージョンを適宜設定します。\nこれらのオプションは、UnityプロジェクトのPlatformを変更すると、\nシーンに自動的に適用されます。", + "SettingsDebugOptions": "Debugオプション", + "SettingsDebugReveal": "EQS_Data管理用 GameObjectを表示", + "SettingsFeedback": "プログラムに何か問題があれば、GitHubのコードを調べるか、Twitterで私に連絡してください!", + "SettingsGithub": "Github", + "SettingsTwitter": "Twitter", + + "PopupDeleteWarning": "シーンから「EasyQuestSwitch」が削除され、データもすべて削除されます。続行しますか?", + "PopupTargetChanged": "前回のBuild実行時と違うPlatformへ変更されました。EQSを{0}用で適用してください。\nマニュアルで適用する場合は設定メニューから実行可能です。", + "PopupAccept": "はい", + "PopupDecline": "いいえ", + + "ListSetupEQS": "Sceneに「EasyQuestSwitch」を追加する", + "ListExpand": "すべてを展開", + "ListFold": "すべてを畳む", + + "LogUnsupportedComponent": "これはサポートされていないコンポーネントです", + "LogComponentExists": "このコンポーネントは既にEQSに設定されています。", + "LogSwitchMissing": "設定番号{0}の対象コンポーネントは設定漏れがあるか関連付けがされていません。", + "LogSwitchTryCatch": "設定番号{0}、({1})は変換中にエラーしました。{2}", + "LogSwitchSuccess": "ビルドターゲット {0} のシーン変更を「EasyQuestSwitch」が適用しました。", + "LogSwitchFailure": "こちらはサポートされていないビルドターゲットです。" +} \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local/jp.json.meta b/EasyQuestSwitch/Resources/EQS_Localizations/jp.json.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local/jp.json.meta rename to EasyQuestSwitch/Resources/EQS_Localizations/jp.json.meta diff --git a/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Logo.png b/EasyQuestSwitch/Resources/EQS_Logo.png similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/Resources/EQS_Logo.png rename to EasyQuestSwitch/Resources/EQS_Logo.png diff --git a/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Logo.png.meta b/EasyQuestSwitch/Resources/EQS_Logo.png.meta similarity index 100% rename from VRCPrefabs/EasyQuestSwitch/Resources/EQS_Logo.png.meta rename to EasyQuestSwitch/Resources/EQS_Logo.png.meta diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/EQS_Fields.cs b/VRCPrefabs/EasyQuestSwitch/EQS_Types/EQS_Fields.cs deleted file mode 100644 index edc9854..0000000 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/EQS_Fields.cs +++ /dev/null @@ -1,69 +0,0 @@ -#if UNITY_EDITOR -using System; -using UnityEditor; -using UnityEngine; -using UnityEngine.Rendering; - - -namespace EasyQuestSwitch.Fields -{ - [Serializable] - public class SharedObject - { - public T PC; - public T Quest; - - public void Setup(T obj) - { - PC = Quest = obj; - } - } - - [Serializable] - public class SharedBool : SharedObject {} - [Serializable] - public class SharedInt : SharedObject { } - [Serializable] - public class SharedVector3 : SharedObject { } - [Serializable] - public class SharedString : SharedObject { } - [Serializable] - public class SharedFloat : SharedObject { } - [Serializable] - public class SharedShader : SharedObject {} - [Serializable] - public class SharedMaterial : SharedObject {} - [Serializable] - public class SharedMesh : SharedObject {} - [Serializable] - public class SharedTransform : SharedObject {} - [Serializable] - public class SharedLayerMask : SharedObject {} - - #region GameObject - [Serializable] - public class SharedTag : SharedObject { } - [Serializable] - public class SharedLayer : SharedObject { } - [Serializable] - public class SharedStaticEditorFlags : SharedObject { } - #endregion - - #region Animator - [Serializable] - public class SharedRuntimeAnimatorController : SharedObject {} - [Serializable] - public class SharedAnimatorCullingMode : SharedObject {} - #endregion - - #region Renderer - [Serializable] - public class SharedLightProbeUsage : SharedObject {} - [Serializable] - public class SharedReflectionProbeUsage : SharedObject {} - [Serializable] - public class SharedShadowCastingMode : SharedObject {} - #endregion - -} -#endif diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Material.cs b/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Material.cs deleted file mode 100644 index aadcc42..0000000 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_Material.cs +++ /dev/null @@ -1,39 +0,0 @@ -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine; -using EasyQuestSwitch.Fields; - -namespace EasyQuestSwitch.Types -{ - public class Type_Material : Type_Base - { - [System.NonSerialized] - private Material type; - - public SharedShader Shader = new SharedShader(); - - public override void Setup(Object type) - { - Material material = (Material)type; - Shader.Setup(material.shader); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - Material material = (Material)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - material.shader = Shader.PC; - break; - case BuildTarget.Android: - material.shader = Shader.Quest; - break; - default: - break; - } - } - } -} -#endif - diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_MeshCollider.cs b/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_MeshCollider.cs deleted file mode 100644 index 06e531c..0000000 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/Type_MeshCollider.cs +++ /dev/null @@ -1,48 +0,0 @@ -#if UNITY_EDITOR -using UnityEditor; -using UnityEngine; -using EasyQuestSwitch.Fields; - -namespace EasyQuestSwitch.Types -{ - public class Type_MeshCollider : Type_Collider - { - [System.NonSerialized] - private MeshCollider type; - - public SharedBool Convex = new SharedBool(); - public SharedMesh SharedMesh = new SharedMesh(); - - public override void Setup(Object type) - { - base.Setup(type); - MeshCollider component = (MeshCollider)type; - Convex.Setup(component.convex); - SharedMesh.Setup(component.sharedMesh); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - MeshCollider component = (MeshCollider)type; - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.enabled = Enabled.PC; - component.isTrigger = IsTrigger.PC && Convex.PC ? true : false; - component.convex = Convex.PC; - component.sharedMesh = SharedMesh.PC; - break; - case BuildTarget.Android: - component.enabled = Enabled.Quest; - component.isTrigger = IsTrigger.Quest && Convex.Quest ? true : false; - component.convex = Convex.Quest; - component.sharedMesh = SharedMesh.Quest; - break; - default: - break; - } - } - } -} -#endif - diff --git a/VRCPrefabs/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection.cs b/VRCPrefabs/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection.cs deleted file mode 100644 index c6fbd16..0000000 --- a/VRCPrefabs/EasyQuestSwitch/EQS_Types/VRC/Type_VRC_MirrorReflection.cs +++ /dev/null @@ -1,67 +0,0 @@ -#if UNITY_EDITOR && (VRC_SDK_VRCSDK2 || VRC_SDK_VRCSDK3) -using UnityEditor; -using UnityEngine; -#if VRC_SDK_VRCSDK2 -using VRCSDK2; -#endif -#if VRC_SDK_VRCSDK3 -using VRC.SDK3.Components; -#endif -using EasyQuestSwitch.Fields; - - -namespace EasyQuestSwitch.Types -{ - public class Type_VRC_MirrorReflection : Type_Behaviour - { - [System.NonSerialized] -#if VRC_SDK_VRCSDK2 - private VRC_MirrorReflection type; -#elif VRC_SDK_VRCSDK3 - private VRCMirrorReflection type; -#endif - - public SharedBool DisablePixelLights = new SharedBool(); - public SharedBool TurnOffMirrorOcclusion = new SharedBool(); - public SharedLayerMask ReflectLayers = new SharedLayerMask(); - - public override void Setup(Object type) - { - base.Setup(type); -#if VRC_SDK_VRCSDK2 - VRC_MirrorReflection component = (VRC_MirrorReflection)type; -#elif VRC_SDK_VRCSDK3 - VRCMirrorReflection component = (VRCMirrorReflection)type; -#endif - DisablePixelLights.Setup(component.m_DisablePixelLights); - TurnOffMirrorOcclusion.Setup(component.TurnOffMirrorOcclusion); - ReflectLayers.Setup(component.m_ReflectLayers); - } - - public override void Process(Object type, BuildTarget buildTarget) - { - base.Process(type, buildTarget); -#if VRC_SDK_VRCSDK2 - VRC_MirrorReflection component = (VRC_MirrorReflection)type; -#elif VRC_SDK_VRCSDK3 - VRCMirrorReflection component = (VRCMirrorReflection)type; -#endif - switch (buildTarget) - { - case BuildTarget.StandaloneWindows64: - component.m_DisablePixelLights = DisablePixelLights.PC; - component.TurnOffMirrorOcclusion = TurnOffMirrorOcclusion.PC; - component.m_ReflectLayers = ReflectLayers.PC; - break; - case BuildTarget.Android: - component.m_DisablePixelLights = DisablePixelLights.Quest; - component.TurnOffMirrorOcclusion = TurnOffMirrorOcclusion.Quest; - component.m_ReflectLayers = ReflectLayers.Quest; - break; - default: - break; - } - } - } -} -#endif diff --git a/VRCPrefabs/EasyQuestSwitch/Editor/EQS_Window.cs b/VRCPrefabs/EasyQuestSwitch/Editor/EQS_Window.cs deleted file mode 100644 index f4ca8d5..0000000 --- a/VRCPrefabs/EasyQuestSwitch/Editor/EQS_Window.cs +++ /dev/null @@ -1,350 +0,0 @@ -using UnityEngine; -using UnityEditor; -using UnityEditorInternal; -using UnityEditor.SceneManagement; -using UnityEngine.SceneManagement; -using EasyQuestSwitch.Fields; -using System.IO; - -namespace EasyQuestSwitch -{ - - public class EQS_Window : EditorWindow - { - - [MenuItem("VRC Prefabs/Easy Quest Switch")] - static void Init() - { - EQS_Window window = (EQS_Window)EditorWindow.GetWindow(typeof(EQS_Window), false, "Easy Quest Switch"); - window.Show(); - } - - private SerializedObject serializedObject; - private SerializedProperty eqsData; - private ReorderableList reorderableList; - private EQS_Localization localization; - - private EQS_Data _data; - private EQS_Data data - { - get - { - if(_data == null) _data = GameObject.Find("EQS_DATA")?.GetComponent(); - return _data; - } - set - { - _data = value; - } - } - - private Vector2 scrollPos; - - private Texture2D logo; - private Texture2D headerBG; - - private bool settingsMenu; - private int chosenLanguage; - - private void OnEnable() - { - serializedObject = null; - EditorSceneManager.activeSceneChangedInEditMode += OnSceneChanged; - Undo.undoRedoPerformed += OnUndoRedo; - - minSize = new Vector2(512, 320); - - localization = new EQS_Localization(); - localization.LoadLanguages(); - chosenLanguage = EditorPrefs.GetInt("EQS_Language", 0); - localization.SetLanguage(chosenLanguage); - - if (data != null) SetupEQS(); - - logo = (Texture2D)Resources.Load("EQS_Logo", typeof(Texture2D)); - headerBG = new Texture2D(1, 1); - headerBG.SetPixel(0, 0, new Color(0, 0.8f, 0.3f)); - headerBG.Apply(); - } - - private void CreateEQS() - { - GameObject sceneRefGO = new GameObject("EQS_DATA"); - EQS_Data sceneRef = sceneRefGO.AddComponent(); - sceneRefGO.tag = "EditorOnly"; - sceneRefGO.hideFlags = HideFlags.HideInHierarchy; - data = sceneRef; - SetupEQS(); - } - - private void SetupEQS() - { - serializedObject = new SerializedObject(data); - eqsData = serializedObject.FindProperty("Objects"); - - reorderableList = new ReorderableList(serializedObject, eqsData, true, false, false, false); - reorderableList.drawElementCallback += DrawElementCallback; - reorderableList.elementHeightCallback += ElementHeightCallback; - reorderableList.drawElementBackgroundCallback += DrawElementBackgroundCallback; - reorderableList.onAddCallback += OnAddCallback; - reorderableList.onRemoveCallback += OnRemoveCallback; - reorderableList.onMouseDragCallback += OnMouseDragCallback; - reorderableList.showDefaultBackground = false; - reorderableList.headerHeight = 0; - } - - private void DestroyEQS() - { - serializedObject = null; - DestroyImmediate(data.gameObject); - _data = data = null; - } - - private void OnUndoRedo() => Repaint(); - - private void OnSceneChanged(Scene current, Scene next) => OnEnable(); - - #region ReorderableList callbacks - - private void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused) - { - rect.width = EditorGUIUtility.currentViewWidth - GUI.skin.verticalScrollbar.fixedWidth - 32; - float oldY = rect.y; - rect.y += EditorGUIUtility.standardVerticalSpacing * 2; - - SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(index); - SerializedProperty elementTarget = element.FindPropertyRelative("Target"); - EditorGUI.BeginChangeCheck(); - EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width + 4, EditorGUIUtility.singleLineHeight), elementTarget, GUIContent.none); - if(EditorGUI.EndChangeCheck()) - { - serializedObject.ApplyModifiedProperties(); - data.ValidateData(index); - } - - UnityEngine.Object elementTypeObj = element.FindPropertyRelative("Type").objectReferenceValue; - if (elementTypeObj != null) - { - // Create foldout - SerializedProperty showFoldout = element.FindPropertyRelative("Foldout"); - rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing * 4; - showFoldout.boolValue = EditorGUI.Foldout(new Rect(rect.x, rect.y, EditorGUIUtility.currentViewWidth - GUI.skin.verticalScrollbar.fixedWidth, EditorGUIUtility.singleLineHeight), showFoldout.boolValue, ""); - if (showFoldout.boolValue) - { - PlatformLabel platformLabel = new PlatformLabel(); - platformLabel.OnGUI(rect, null, null); - - SerializedObject elementType = new SerializedObject(elementTypeObj); - SerializedProperty elementTypeIterator = elementType.GetIterator(); - elementTypeIterator.NextVisible(true); - while (elementTypeIterator.NextVisible(false)) - { - elementTypeIterator.serializedObject.Update(); - rect.y += EditorGUI.GetPropertyHeight(elementTypeIterator, false) * 1.5f; - EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), elementTypeIterator, true); - if (elementTypeIterator.isArray && elementTypeIterator.isExpanded && elementTypeIterator.arraySize != 0) - { - for (int i = 0; i < elementTypeIterator.arraySize; i++) - { - rect.y += EditorGUI.GetPropertyHeight(elementTypeIterator.GetArrayElementAtIndex(i), true) * 1.5f; - } - } - elementTypeIterator.serializedObject.ApplyModifiedProperties(); - } - } - } - - rect.x = 0; - rect.y = oldY + ElementHeightCallback(index) - EditorGUIUtility.standardVerticalSpacing; - rect.width = EditorGUIUtility.currentViewWidth; - rect.height = 1; - EditorGUI.DrawRect(rect, Color.grey); - } - - private float ElementHeightCallback(int index) - { - SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(index); - float propertyHeight = EditorGUI.GetPropertyHeight(element, false); // true = include children - float nestedHeight = 0.0f; - if(element.FindPropertyRelative("Foldout").boolValue) - { - UnityEngine.Object elementTypeObj = element.FindPropertyRelative("Type").objectReferenceValue; - if(elementTypeObj != null) - { - SerializedObject elementType = new SerializedObject(elementTypeObj); - SerializedProperty elementTypeIterator = elementType.GetIterator(); - bool enableChildren = true; - while (elementTypeIterator.NextVisible(enableChildren)) - { - if (elementTypeIterator.isExpanded && elementTypeIterator.isArray && elementTypeIterator.arraySize != 0) - { - nestedHeight += EditorGUI.GetPropertyHeight(elementTypeIterator, false) * 1.5f; - for (int i = 0; i < elementTypeIterator.arraySize; i++) - { - nestedHeight += EditorGUI.GetPropertyHeight(elementTypeIterator.GetArrayElementAtIndex(i), true) * 1.5f; - } - } - else - { - nestedHeight += EditorGUI.GetPropertyHeight(elementTypeIterator, true) * 1.5f; - } - enableChildren = false; - } - } - } - else - { - nestedHeight += EditorGUIUtility.singleLineHeight; - } - float spacing = EditorGUIUtility.singleLineHeight; - return propertyHeight + nestedHeight + spacing; - } - - private void DrawElementBackgroundCallback(Rect rect, int index, bool isActive, bool isFocused) - { - if(reorderableList.count > 0) - { - if (reorderableList.serializedProperty != null) - { - Rect newRect = new Rect(rect); - newRect.height = EditorGUI.GetPropertyHeight(reorderableList.serializedProperty.GetArrayElementAtIndex(index), false) * 2f + EditorGUIUtility.singleLineHeight; - EditorGUI.DrawRect(newRect, new Color(0, 0, 0, 0.15f)); - } - } - ReorderableList.defaultBehaviours.DrawElementBackground(rect, index, isActive, isFocused, reorderableList.draggable); - } - - private void OnAddCallback(ReorderableList list) - { - int index = list.serializedProperty.arraySize; - list.serializedProperty.arraySize++; - list.index = index; - SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(index); - element.FindPropertyRelative("Target").objectReferenceValue = null; - element.FindPropertyRelative("Type").objectReferenceValue = null; - element.FindPropertyRelative("Foldout").boolValue = false; - } - - private void OnRemoveCallback(ReorderableList list) - { - if (list.count == 0) return; - SerializedProperty element = list.serializedProperty.GetArrayElementAtIndex(list.index); - element.FindPropertyRelative("Target").objectReferenceValue = null; - UnityEngine.Object elementObj = element.FindPropertyRelative("Type").objectReferenceValue; - if(elementObj != null) DestroyImmediate(elementObj); - ReorderableList.defaultBehaviours.DoRemoveButton(list); - } - - private void OnMouseDragCallback(ReorderableList list) - { - SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(list.index); - SerializedProperty showFoldout = element.FindPropertyRelative("Foldout"); - if (showFoldout.boolValue) showFoldout.boolValue = false; - } - #endregion - - private void OnGUI() - { - if(serializedObject != null) serializedObject.Update(); - - // Header - GUIStyle headerStyle = new GUIStyle("Box"); - GUILayout.BeginHorizontal(headerStyle); - headerStyle.normal.background = headerBG; - GUILayout.BeginHorizontal(headerStyle); - GUILayout.FlexibleSpace(); - GUILayout.Box(logo, GUILayout.Width(150), GUILayout.Height(70)); - GUILayout.FlexibleSpace(); - Rect settingsRect = GUILayoutUtility.GetLastRect(); - settingsRect.width /= 2; - settingsRect.x += settingsRect.width; - settingsRect.height = EditorGUIUtility.singleLineHeight + 2; - settingsMenu = GUI.Toggle(settingsRect, settingsMenu, localization.Current.SettingsButton, new GUIStyle("Button")); - GUILayout.EndHorizontal(); - GUILayout.EndHorizontal(); - - if(settingsMenu) - { - if (EditorPrefs.GetInt("CacheServerMode") == 2) // CacheServerMode 2 = Disabled (not local or remote) - { - EditorGUILayout.BeginHorizontal(); - GUIContent helpBoxContent = new GUIContent(localization.Current.SettingsCacheWarning, EditorGUIUtility.IconContent("console.warnicon").image); - GUIContent helpBoxButton = new GUIContent(localization.Current.SettingsCacheButton); - float width = GUI.skin.button.CalcSize(helpBoxButton).x - 11; - float height = EditorStyles.helpBox.CalcHeight(helpBoxContent, EditorGUIUtility.currentViewWidth - width); - GUILayout.Box(helpBoxContent, EditorStyles.helpBox); - if (GUILayout.Button(helpBoxButton, GUILayout.Height(height))) SettingsService.OpenUserPreferences("Preferences/Cache Server"); - EditorGUILayout.EndHorizontal(); - } - - GUILayout.BeginHorizontal(); - GUILayout.Label(new GUIContent(localization.Current.SettingsLanguage)); - EditorGUI.BeginChangeCheck(); - chosenLanguage = EditorGUILayout.Popup(chosenLanguage, localization.GetLanguages()); - if(EditorGUI.EndChangeCheck()) - { - localization.SetLanguage(chosenLanguage); - EditorPrefs.SetInt("EQS_Language", chosenLanguage); - } - if (serializedObject == null) EditorGUI.BeginDisabledGroup(true); - if (GUILayout.Button(localization.Current.SettingsApplyPC)) data.CheckTarget(BuildTarget.StandaloneWindows64); - if (GUILayout.Button(localization.Current.SettingsApplyQuest)) data.CheckTarget(BuildTarget.Android); - GUILayout.EndHorizontal(); - if (GUILayout.Button(localization.Current.SettingsRemoveEQS, GUILayout.Height(32))) - { - if (EditorUtility.DisplayDialog(string.Empty, localization.Current.PopupDeleteWarning, localization.Current.PopupAccept, localization.Current.PopupDecline)) - { - DestroyEQS(); - } - } - if (serializedObject == null) EditorGUI.EndDisabledGroup(); - GUILayout.BeginVertical(); - GUILayout.Box(localization.Current.SettingsExplanation, EditorStyles.wordWrappedLabel); - GUILayout.FlexibleSpace(); - GUILayout.BeginHorizontal(); - GUILayout.Box(localization.Current.SettingsFeedback, EditorStyles.wordWrappedLabel); - if(GUILayout.Button(localization.Current.SettingsTwitter)) Application.OpenURL("https://twitter.com/JordoVR"); - if(GUILayout.Button(localization.Current.SettingsGithub)) Application.OpenURL("https://github.com/JordoVR/EasyQuestSwitch"); - GUILayout.EndHorizontal(); - GUILayout.EndVertical(); - - } - else - { - if(data == null) - { - if(GUILayout.Button(localization.Current.ListSetupEQS)) CreateEQS(); - } - else - { - GUILayout.BeginHorizontal(); - if (GUILayout.Toggle(false, localization.Current.ListExpand, EditorStyles.toolbarButton)) - { - for (int i = 0; i < reorderableList.serializedProperty.arraySize; i++) - { - SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(i); - if (element.FindPropertyRelative("Type").objectReferenceValue != null) element.FindPropertyRelative("Foldout").boolValue = true; - } - Repaint(); - } - if (GUILayout.Toggle(false, localization.Current.ListFold, EditorStyles.toolbarButton)) - { - for (int i = 0; i < reorderableList.serializedProperty.arraySize; i++) - { - SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(i); - element.FindPropertyRelative("Foldout").boolValue = false; - } - Repaint(); - } - if (GUILayout.Button("+", EditorStyles.toolbarButton)) OnAddCallback(reorderableList); - if (GUILayout.Button("-", EditorStyles.toolbarButton)) OnRemoveCallback(reorderableList); - GUILayout.EndHorizontal(); - scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, GUI.skin.scrollView); - reorderableList.DoLayoutList(); - EditorGUILayout.EndScrollView(); - } - } - if(serializedObject != null) serializedObject.ApplyModifiedProperties(); - } - } -} \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/LICENSE b/VRCPrefabs/EasyQuestSwitch/LICENSE deleted file mode 100644 index fdcea4a..0000000 --- a/VRCPrefabs/EasyQuestSwitch/LICENSE +++ /dev/null @@ -1,32 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2020, Jordo -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -4. Redistribution of this software in source or binary form shall be free - of all charges or fees to the recipient of this software. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local/en.json b/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local/en.json deleted file mode 100644 index 89105e9..0000000 --- a/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local/en.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "DisplayName": "English", - - "SettingsButton" : "Settings", - "SettingsLanguage" : "Language", - "SettingsApplyPC" : "Force apply PC settings", - "SettingsApplyQuest" : "Force apply Quest settings", - "SettingsRemoveEQS" : "Remove Easy Quest Switch from the scene", - "SettingsCacheWarning" : "Your cache server is not enabled, you may experience long switching times! It is best to set it to local or remote. (Remote requires additional steps)", - "SettingsCacheButton" : "Open settings", - "SettingsExplanation" : "Welcome to Easy Quest Switch! To begin with, add a new element to the list with '+' and drag a component from the scene into the object field, several options related to that component will appear, you can configure each for the PC or Quest version of the scene respectively.\nThese options will be automatically applied to the scene when you change the Unity project build target", - "SettingsFeedback" : "If you have any issues with the program, do not hesitate to look up the github code or contact me on twitter!", - "SettingsGithub" : "Github", - "SettingsTwitter" : "Twitter", - - "PopupDeleteWarning" : "This will delete EasyQuestSwitch from the scene and all its data, are you sure?", - "PopupAccept" : "Yes", - "PopupDecline" : "No", - - "ListSetupEQS" : "Setup Easy Quest Switch in the scene", - "ListExpand" : "Expand all", - "ListFold" : "Fold all", - - "LogUnsupportedComponent" : "This is an unsupported component", - "LogSwitchSuccess" : "EasyQuestSwitch applied the scene changes of build target {0}", - "LogSwitchFailure" : "Switched to an unsupported build target" -} \ No newline at end of file diff --git a/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local/jp.json b/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local/jp.json deleted file mode 100644 index 2b1658a..0000000 --- a/VRCPrefabs/EasyQuestSwitch/Resources/EQS_Local/jp.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "DisplayName": "日本語", - - "SettingsButton" : "設定", - "SettingsLanguage" : "言語", - "SettingsApplyPC" : "PCの設定を強制的に適用", - "SettingsApplyQuest" : "Questの設定を強制的に適用", - "SettingsRemoveEQS" : "「EasyQuestSwitch」をSceneから削除", - "SettingsCacheWarning" : "キャッシュサーバーが有効になっていない場合、切り替え時間が長くなる可能性があります。\nLocalかRemoteに設定するのがおすすめです。\n(Remoteの場合は追加の手順が必要です)", - "SettingsCacheButton" : "設定を開く", - "SettingsExplanation" : "ようこそ、「EasyQuestSwitch」へ、まずリストに機能を使いたいGameObjectを「+」で追加し\nシーンの中から任意のコンポーネントを設定欄にドラッグ&ドロップします。\nすると、そのコンポーネントに関連するオプションが表示されますので、\nSceneのPCバージョンとQuestバージョンを適宜設定します。\nこれらのオプションは、UnityプロジェクトのPlatformを変更すると、\nシーンに自動的に適用されます。", - "SettingsFeedback" : "プログラムに何か問題があれば、GitHubのコードを調べるか、Twitterで私に連絡してください!", - "SettingsGithub" : "Github", - "SettingsTwitter" : "Twitter", - - "PopupDeleteWarning" : "シーンから「EasyQuestSwitch」が削除され、データもすべて削除されます。続行しますか?", - "PopupAccept" : "はい", - "PopupDecline" : "いいえ", - - "ListSetupEQS" : "Sceneに「EasyQuestSwitch」を追加する", - "ListExpand" : "すべてを展開", - "ListFold" : "すべてを畳む", - - "LogUnsupportedComponent" : "これはサポートされていないコンポーネントです", - "LogSwitchSuccess" : "ビルドターゲット {0} のシーン変更を「EasyQuestSwitch」が適用しました。", - "LogSwitchFailure" : "こちらはサポートされていないビルドターゲットです。" -} \ No newline at end of file