diff options
Diffstat (limited to 'Assets/Plugins/Sirenix/Odin Inspector/Scripts')
27 files changed, 1267 insertions, 0 deletions
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor.meta new file mode 100644 index 00000000..809832d1 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 51d97d64dbac6434cbb39359e4346f89 +folderAsset: yes +timeCreated: 1602083739 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/AssemblyImportSettingsAutomation.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/AssemblyImportSettingsAutomation.cs new file mode 100644 index 00000000..5722a91e --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/AssemblyImportSettingsAutomation.cs @@ -0,0 +1,134 @@ +//-----------------------------------------------------------------------
+// <copyright file="AssemblyImportSettingsAutomation.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+#if UNITY_EDITOR && UNITY_5_6_OR_NEWER
+
+namespace Sirenix.OdinInspector.Editor
+{
+ using System.IO;
+ using System.Collections.Generic;
+ using Sirenix.Serialization.Utilities.Editor;
+ using Sirenix.Utilities;
+ using UnityEditor;
+ using UnityEditor.Build;
+
+#if UNITY_2018_1_OR_NEWER
+ using UnityEditor.Build.Reporting;
+#endif
+
+ public class AssemblyImportSettingsAutomation :
+#if UNITY_2018_1_OR_NEWER
+ IPreprocessBuildWithReport
+#else
+ IPreprocessBuild
+#endif
+ {
+
+ public int callbackOrder { get { return -1500; } }
+
+ private static void ConfigureImportSettings()
+ {
+ if (EditorOnlyModeConfig.Instance.IsEditorOnlyModeEnabled() || ImportSettingsConfig.Instance.AutomateBeforeBuild == false)
+ {
+ return;
+ }
+
+ var assemblyDir = new DirectoryInfo(SirenixAssetPaths.SirenixAssembliesPath).FullName;
+ var projectAssetsPath = Directory.GetCurrentDirectory().TrimEnd('\\', '/');
+
+ var isPackage = PathUtilities.HasSubDirectory(new DirectoryInfo(projectAssetsPath), new DirectoryInfo(assemblyDir)) == false;
+
+ var aotDirPath = assemblyDir + "NoEmitAndNoEditor/";
+ var jitDirPath = assemblyDir + "NoEditor/";
+
+ var aotDir = new DirectoryInfo(aotDirPath);
+ var jitDir = new DirectoryInfo(jitDirPath);
+
+ var aotAssemblies = new List<string>();
+ var jitAssemblies = new List<string>();
+
+ foreach (var file in aotDir.GetFiles("*.dll"))
+ {
+ string path = file.FullName;
+ if (isPackage)
+ {
+ path = SirenixAssetPaths.SirenixAssembliesPath.TrimEnd('\\', '/') + "/" + path.Substring(assemblyDir.Length);
+ }
+ else
+ {
+ path = path.Substring(projectAssetsPath.Length + 1);
+ }
+
+ aotAssemblies.Add(path);
+ }
+
+ foreach (var file in jitDir.GetFiles("*.dll"))
+ {
+ string path = file.FullName;
+ if (isPackage)
+ {
+ path = SirenixAssetPaths.SirenixAssembliesPath.TrimEnd('\\', '/') + "/" + path.Substring(assemblyDir.Length);
+ }
+ else
+ {
+ path = path.Substring(projectAssetsPath.Length + 1);
+ }
+
+ jitAssemblies.Add(path);
+ }
+
+ AssetDatabase.StartAssetEditing();
+ try
+ {
+ var platform = EditorUserBuildSettings.activeBuildTarget;
+
+ if (AssemblyImportSettingsUtilities.IsJITSupported(
+ platform,
+ AssemblyImportSettingsUtilities.GetCurrentScriptingBackend(),
+ AssemblyImportSettingsUtilities.GetCurrentApiCompatibilityLevel()))
+ {
+ ApplyImportSettings(platform, aotAssemblies.ToArray(), OdinAssemblyImportSettings.ExcludeFromAll);
+ ApplyImportSettings(platform, jitAssemblies.ToArray(), OdinAssemblyImportSettings.IncludeInBuildOnly);
+ }
+ else
+ {
+ ApplyImportSettings(platform, aotAssemblies.ToArray(), OdinAssemblyImportSettings.IncludeInBuildOnly);
+ ApplyImportSettings(platform, jitAssemblies.ToArray(), OdinAssemblyImportSettings.ExcludeFromAll);
+ }
+ }
+ finally
+ {
+ AssetDatabase.StopAssetEditing();
+ }
+ }
+
+ private static void ApplyImportSettings(BuildTarget platform, string[] assemblyPaths, OdinAssemblyImportSettings importSettings)
+ {
+ for (int i = 0; i < assemblyPaths.Length; i++)
+ {
+ AssemblyImportSettingsUtilities.SetAssemblyImportSettings(platform, assemblyPaths[i], importSettings);
+ }
+ }
+
+#if UNITY_2018_1_OR_NEWER
+
+ void IPreprocessBuildWithReport.OnPreprocessBuild(BuildReport report)
+ {
+ ConfigureImportSettings();
+ }
+
+#else
+
+ void IPreprocessBuild.OnPreprocessBuild(BuildTarget target, string path)
+ {
+ ConfigureImportSettings();
+ }
+
+#endif
+ }
+}
+
+#endif // UNITY_EDITOR && UNITY_5_6_OR_NEWER
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/AssemblyImportSettingsAutomation.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/AssemblyImportSettingsAutomation.cs.meta new file mode 100644 index 00000000..55dc9d8e --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/AssemblyImportSettingsAutomation.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: d4d815a2bfd253342bfd6542c08315fb
+timeCreated: 1533296750
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/BuildAOTAutomation.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/BuildAOTAutomation.cs new file mode 100644 index 00000000..c4ec6f45 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/BuildAOTAutomation.cs @@ -0,0 +1,79 @@ +//-----------------------------------------------------------------------
+// <copyright file="BuildAOTAutomation.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+#if UNITY_EDITOR && UNITY_5_6_OR_NEWER
+
+namespace Sirenix.Serialization.Internal
+{
+ using Sirenix.Serialization;
+ using UnityEditor;
+ using UnityEditor.Build;
+ using System.IO;
+ using System;
+
+#if UNITY_2018_1_OR_NEWER
+
+ using UnityEditor.Build.Reporting;
+
+#endif
+
+#if UNITY_2018_1_OR_NEWER
+ public class PreBuildAOTAutomation : IPreprocessBuildWithReport
+#else
+ public class PreBuildAOTAutomation : IPreprocessBuild
+#endif
+ {
+ public int callbackOrder { get { return -1000; } }
+
+ public void OnPreprocessBuild(BuildTarget target, string path)
+ {
+ if (AOTGenerationConfig.Instance.ShouldAutomationGeneration(target))
+ {
+ AOTGenerationConfig.Instance.ScanProject();
+ AOTGenerationConfig.Instance.GenerateDLL();
+ }
+ }
+
+#if UNITY_2018_1_OR_NEWER
+
+ public void OnPreprocessBuild(BuildReport report)
+ {
+ this.OnPreprocessBuild(report.summary.platform, report.summary.outputPath);
+ }
+
+#endif
+ }
+
+#if UNITY_2018_1_OR_NEWER
+ public class PostBuildAOTAutomation : IPostprocessBuildWithReport
+#else
+ public class PostBuildAOTAutomation : IPostprocessBuild
+#endif
+ {
+ public int callbackOrder { get { return -1000; } }
+
+ public void OnPostprocessBuild(BuildTarget target, string path)
+ {
+ if (AOTGenerationConfig.Instance.DeleteDllAfterBuilds && AOTGenerationConfig.Instance.ShouldAutomationGeneration(target))
+ {
+ Directory.Delete(AOTGenerationConfig.Instance.AOTFolderPath, true);
+ File.Delete(AOTGenerationConfig.Instance.AOTFolderPath.TrimEnd('/', '\\') + ".meta");
+ AssetDatabase.Refresh();
+ }
+ }
+
+#if UNITY_2018_1_OR_NEWER
+
+ public void OnPostprocessBuild(BuildReport report)
+ {
+ this.OnPostprocessBuild(report.summary.platform, report.summary.outputPath);
+ }
+
+#endif
+ }
+}
+
+#endif // UNITY_EDITOR && UNITY_5_6_OR_NEWER
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/BuildAOTAutomation.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/BuildAOTAutomation.cs.meta new file mode 100644 index 00000000..b7bf4433 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/BuildAOTAutomation.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: dd3672808cdf76541aa3d383c87a5616
+timeCreated: 1514538277
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/EnsureOdinInspectorDefine.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/EnsureOdinInspectorDefine.cs new file mode 100644 index 00000000..be82f389 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/EnsureOdinInspectorDefine.cs @@ -0,0 +1,121 @@ +//-----------------------------------------------------------------------
+// <copyright file="EnsureOdinInspectorDefine.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+#if UNITY_EDITOR
+
+namespace Sirenix.Utilities
+{
+ using System;
+ using System.Linq;
+ using UnityEditor;
+
+ /// <summary>
+ /// Defines the ODIN_INSPECTOR symbol.
+ /// </summary>
+ internal static class EnsureOdinInspectorDefine
+ {
+ private static readonly string[] DEFINES = new string[] { "ODIN_INSPECTOR", "ODIN_INSPECTOR_3" };
+
+ [InitializeOnLoadMethod]
+ private static void EnsureScriptingDefineSymbol()
+ {
+ var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup;
+
+ if (currentTarget == BuildTargetGroup.Unknown)
+ {
+ return;
+ }
+
+ var definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTarget).Trim();
+ var defines = definesString.Split(';');
+
+ bool changed = false;
+
+ foreach (var define in DEFINES)
+ {
+ if (defines.Contains(define) == false)
+ {
+ if (definesString.EndsWith(";", StringComparison.InvariantCulture) == false)
+ {
+ definesString += ";";
+ }
+
+ definesString += define;
+ changed = true;
+ }
+ }
+
+ if (changed)
+ {
+ PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, definesString);
+ }
+ }
+ }
+
+ //
+ // If you have a project where only some users have Odin, and you want to utilize the ODIN_INSPECTOR
+ // define symbol. Then, in order to only define the symbol for those with Odin, you can delete this script,
+ // which prevent ODIN_INSPECTOR from being added to the Unity's player settings.
+ //
+ // And instead automatically add the ODIN_INSPECTOR define to an mcs.rsp file if Odin exists using the script below.
+ // You can then ignore the mcs.rsp file in source control.
+ //
+ // Remember to manually remove the ODIN_INSPECTOR define symbol in player settings after removing this script.
+ //
+ // static class AddOdinInspectorDefineIfOdinExist
+ // {
+ // private const string ODIN_MCS_DEFINE = "-define:ODIN_INSPECTOR";
+ //
+ // [InitializeOnLoadMethod]
+ // private static void AddOrRemoveOdinDefine()
+ // {
+ // var addDefine = AppDomain.CurrentDomain.GetAssemblies().Any(x => x.FullName.StartsWith("Sirenix.OdinInspector.Editor"));
+ //
+ // #if ODIN_INSPECTOR
+ // var hasDefine = true;
+ // #else
+ // var hasDefine = false;
+ // #endif
+ //
+ // if (addDefine == hasDefine)
+ // {
+ // return;
+ // }
+ //
+ // var mcsPath = Path.Combine(Application.dataPath, "mcs.rsp");
+ // var hasMcsFile = File.Exists(mcsPath);
+ //
+ // if (addDefine)
+ // {
+ // var lines = hasMcsFile ? File.ReadAllLines(mcsPath).ToList() : new List<string>();
+ // if (!lines.Any(x => x.Trim() == ODIN_MCS_DEFINE))
+ // {
+ // lines.Add(ODIN_MCS_DEFINE);
+ // File.WriteAllLines(mcsPath, lines.ToArray());
+ // AssetDatabase.Refresh();
+ // }
+ // }
+ // else if (hasMcsFile)
+ // {
+ // var linesWithoutOdinDefine = File.ReadAllLines(mcsPath).Where(x => x.Trim() != ODIN_MCS_DEFINE).ToArray();
+ //
+ // if (linesWithoutOdinDefine.Length == 0)
+ // {
+ // // Optional - Remove the mcs file instead if it doesn't contain any lines.
+ // File.Delete(mcsPath);
+ // }
+ // else
+ // {
+ // File.WriteAllLines(mcsPath, linesWithoutOdinDefine);
+ // }
+ //
+ // AssetDatabase.Refresh();
+ // }
+ // }
+ // }
+}
+
+#endif // UNITY_EDITOR
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/EnsureOdinInspectorDefine.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/EnsureOdinInspectorDefine.cs.meta new file mode 100644 index 00000000..1ab8a33d --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/EnsureOdinInspectorDefine.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: d9763cb398cf6e146b74d6b7bac2fe50
+timeCreated: 1519909294
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/FixBrokenUnityObjectWrapperDrawer.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/FixBrokenUnityObjectWrapperDrawer.cs new file mode 100644 index 00000000..1f30e4e2 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/FixBrokenUnityObjectWrapperDrawer.cs @@ -0,0 +1,208 @@ +//-----------------------------------------------------------------------
+// <copyright file="FixBrokenUnityObjectWrapperDrawer.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+#if UNITY_EDITOR && UNITY_2018_3_OR_NEWER
+#pragma warning disable
+
+namespace Sirenix.OdinInspector.Editor.Drawers
+{
+ using Sirenix.OdinInspector;
+ using Sirenix.OdinInspector.Editor;
+ using Sirenix.Utilities;
+ using Sirenix.Utilities.Editor;
+ using System.Linq;
+ using UnityEditor;
+ using UnityEngine;
+
+ [DrawerPriority(0.001, 0, 0)]
+ public class FixBrokenUnityObjectWrapperDrawer<T> : OdinValueDrawer<T>, IDefinesGenericMenuItems
+ where T : UnityEngine.Component
+ {
+ private const string AUTO_FIX_PREFS_KEY = "TemporarilyBrokenUnityObjectWrapperDrawer.autoFix";
+
+ private bool isBroken = false;
+ private T realWrapperInstance;
+ private bool allowSceneViewObjects;
+ private static bool autoFix;
+
+ protected override void Initialize()
+ {
+ this.allowSceneViewObjects = this.ValueEntry.Property.GetAttribute<AssetsOnlyAttribute>() == null;
+ autoFix = EditorPrefs.HasKey(AUTO_FIX_PREFS_KEY);
+ }
+
+ protected override void DrawPropertyLayout(GUIContent label)
+ {
+ if (!(this.ValueEntry.ValueState == PropertyValueState.NullReference || this.ValueEntry.ValueState == PropertyValueState.ReferenceValueConflict))
+ {
+ this.CallNextDrawer(label);
+ return;
+ }
+
+ if (Event.current.type == EventType.Layout)
+ {
+ this.isBroken = false;
+ var count = this.ValueEntry.ValueCount;
+ for (int i = 0; i < count; i++)
+ {
+ var component = this.ValueEntry.Values[i];
+
+ if (ComponentIsBroken(component, ref this.realWrapperInstance))
+ {
+ this.isBroken = true;
+ break;
+ }
+ }
+
+ if (this.isBroken && autoFix)
+ {
+ this.isBroken = false;
+
+ for (int i = 0; i < this.ValueEntry.ValueCount; i++)
+ {
+ T fixedComponent = null;
+ if (ComponentIsBroken(this.ValueEntry.Values[i], ref fixedComponent) && fixedComponent)
+ {
+ (this.ValueEntry as IValueEntryActualValueSetter<T>).SetActualValue(i, fixedComponent);
+ }
+ }
+
+ this.ValueEntry.Update();
+ }
+ }
+
+ if (!this.isBroken)
+ {
+ this.CallNextDrawer(label);
+ return;
+ }
+
+ var rect = EditorGUILayout.GetControlRect(label != null);
+ var btnRect = rect.AlignRight(20);
+ var controlRect = rect.SetXMax(btnRect.xMin - 5);
+
+ object newInstance = null;
+
+ EditorGUI.BeginChangeCheck();
+ {
+ if (this.ValueEntry.BaseValueType.IsInterface)
+ {
+ newInstance = SirenixEditorFields.PolymorphicObjectField(controlRect,
+ label,
+ this.realWrapperInstance,
+ this.ValueEntry.BaseValueType,
+ this.allowSceneViewObjects);
+ }
+ else
+ {
+ newInstance = SirenixEditorFields.UnityObjectField(
+ controlRect,
+ label,
+ this.realWrapperInstance,
+ this.ValueEntry.BaseValueType,
+ this.allowSceneViewObjects) as Component;
+ }
+ }
+ if (EditorGUI.EndChangeCheck())
+ {
+ this.ValueEntry.WeakSmartValue = newInstance;
+ }
+
+ if (GUI.Button(btnRect, " ", EditorStyles.miniButton))
+ {
+ var popup = new FixBrokenUnityObjectWrapperPopup(this.ValueEntry);
+ OdinEditorWindow.InspectObjectInDropDown(popup, 300);
+ }
+
+ if (Event.current.type == EventType.Repaint)
+ {
+ GUI.DrawTexture(btnRect, EditorIcons.ConsoleWarnicon, ScaleMode.ScaleToFit);
+ }
+ }
+
+ private static bool ComponentIsBroken(T component, ref T realInstance)
+ {
+ var uObj = component;
+ var oObj = (object)uObj;
+
+ if (oObj != null && uObj == null)
+ {
+ var instanceId = uObj.GetInstanceID();
+ if (AssetDatabase.Contains(instanceId))
+ {
+ var path = AssetDatabase.GetAssetPath(instanceId);
+ var realWrapper = AssetDatabase.LoadAllAssetsAtPath(path).FirstOrDefault(n => n.GetInstanceID() == instanceId) as T;
+ if (realWrapper)
+ {
+ realInstance = realWrapper;
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public void PopulateGenericMenu(InspectorProperty property, GenericMenu genericMenu)
+ {
+ if (EditorPrefs.HasKey(AUTO_FIX_PREFS_KEY))
+ {
+ genericMenu.AddItem(new GUIContent("Disable auto-fix of broken prefab instance references"), false, (x) =>
+ {
+ EditorPrefs.DeleteKey(AUTO_FIX_PREFS_KEY);
+ autoFix = false;
+ }, null);
+ }
+ }
+
+ [TypeInfoBox("This asset reference is temporarily broken until the next reload, because of an error in Unity where the C# wrapper object of a prefab asset is destroyed when changes are made to that prefab asset. This error has been reported to Unity.\n\nMeanwhile, Odin can fix this for you by getting a new, valid wrapper object from the asset database and replacing the broken wrapper instance with the new one.")]
+ private class FixBrokenUnityObjectWrapperPopup
+ {
+ private IPropertyValueEntry<T> valueEntry;
+
+ public FixBrokenUnityObjectWrapperPopup(IPropertyValueEntry<T> valueEntry)
+ {
+ this.valueEntry = valueEntry;
+ }
+
+ [HorizontalGroup, Button(ButtonSizes.Large)]
+ public void FixItThisTime()
+ {
+ for (int i = 0; i < this.valueEntry.ValueCount; i++)
+ {
+ var localI = i;
+ T fixedComponent = null;
+ if (ComponentIsBroken(this.valueEntry.Values[i], ref fixedComponent) && fixedComponent)
+ {
+ this.valueEntry.Property.Tree.DelayActionUntilRepaint(() =>
+ {
+ (this.valueEntry as IValueEntryActualValueSetter<T>).SetActualValue(localI, fixedComponent);
+ });
+ }
+ }
+
+ if (GUIHelper.CurrentWindow)
+ {
+ EditorApplication.delayCall += GUIHelper.CurrentWindow.Close;
+ }
+ }
+
+ [HorizontalGroup, Button(ButtonSizes.Large)]
+ public void FixItAlways()
+ {
+ EditorPrefs.SetBool(AUTO_FIX_PREFS_KEY, true);
+ autoFix = true;
+
+ if (GUIHelper.CurrentWindow)
+ {
+ EditorApplication.delayCall += GUIHelper.CurrentWindow.Close;
+ }
+ }
+ }
+ }
+}
+
+#endif
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/FixBrokenUnityObjectWrapperDrawer.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/FixBrokenUnityObjectWrapperDrawer.cs.meta new file mode 100644 index 00000000..f5f98bf8 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/FixBrokenUnityObjectWrapperDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 903c11a9cf3ba6f4e8c653443c6893a0
+timeCreated: 1546967292
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Sirenix.OdinInspector.CompatibilityLayer.Editor.asmdef b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Sirenix.OdinInspector.CompatibilityLayer.Editor.asmdef new file mode 100644 index 00000000..69efdd76 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Sirenix.OdinInspector.CompatibilityLayer.Editor.asmdef @@ -0,0 +1,13 @@ +{ + "name": "Sirenix.OdinInspector.CompatibilityLayer.Editor", + "references": [], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": true, + "autoReferenced": true, + "overrideReferences": false, + "precompiledReferences": [], + "defineConstraints": [] +}
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Sirenix.OdinInspector.CompatibilityLayer.Editor.asmdef.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Sirenix.OdinInspector.CompatibilityLayer.Editor.asmdef.meta new file mode 100644 index 00000000..3c2621de --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Sirenix.OdinInspector.CompatibilityLayer.Editor.asmdef.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e35af134b1b987743b8a6b5f438e9407 +timeCreated: 1602076732 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncListDrawer.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncListDrawer.cs new file mode 100644 index 00000000..a4d00d8b --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncListDrawer.cs @@ -0,0 +1,88 @@ +//-----------------------------------------------------------------------
+// <copyright file="SyncListDrawer.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+#if UNITY_EDITOR && !UNITY_2019_1_OR_NEWER
+#pragma warning disable 0618
+
+namespace Sirenix.OdinInspector.Editor.Drawers
+{
+ using Sirenix.Utilities.Editor;
+ using UnityEditor;
+ using UnityEngine;
+ using UnityEngine.Networking;
+
+ /// <summary>
+ /// SyncList property drawer.
+ /// </summary>
+ [DrawerPriority(0, 0, 2)]
+ public class SyncListDrawer<TList, TElement> : OdinValueDrawer<TList> where TList : SyncList<TElement>
+ {
+ private LocalPersistentContext<bool> visible;
+
+ protected override void Initialize()
+ {
+ this.visible = this.Property.Context.GetPersistent(this, "expanded", GeneralDrawerConfig.Instance.OpenListsByDefault);
+ }
+
+ /// <summary>
+ /// Draws the property.
+ /// </summary>
+ protected override void DrawPropertyLayout(GUIContent label)
+ {
+ var entry = this.ValueEntry;
+ var property = entry.Property;
+ int minCount = int.MaxValue;
+ int maxCount = 0;
+
+ for (int i = 0; i < entry.ValueCount; i++)
+ {
+ if (entry.Values[i].Count > maxCount)
+ {
+ maxCount = entry.Values[i].Count;
+ }
+
+ if (entry.Values[i].Count < minCount)
+ {
+ minCount = entry.Values[i].Count;
+ }
+ }
+
+ SirenixEditorGUI.BeginHorizontalToolbar();
+ this.visible.Value = SirenixEditorGUI.Foldout(this.visible.Value, GUIHelper.TempContent("SyncList " + label.text + " [" + typeof(TList).Name + "]"));
+ EditorGUILayout.LabelField(GUIHelper.TempContent(minCount == maxCount ? (minCount == 0 ? "Empty" : minCount + " items") : minCount + " (" + maxCount + ") items"), SirenixGUIStyles.RightAlignedGreyMiniLabel);
+ SirenixEditorGUI.EndHorizontalToolbar();
+
+ if (SirenixEditorGUI.BeginFadeGroup(this.visible, this.visible.Value))
+ {
+ GUIHelper.PushGUIEnabled(false);
+ SirenixEditorGUI.BeginVerticalList();
+ {
+ var elementLabel = new GUIContent();
+ for (int i = 0; i < maxCount; i++)
+ {
+ SirenixEditorGUI.BeginListItem();
+ elementLabel.text = "Item " + i;
+
+ if (i < minCount)
+ {
+ property.Children[i].Draw(elementLabel);
+ }
+ else
+ {
+ EditorGUILayout.LabelField(elementLabel, SirenixEditorGUI.MixedValueDashChar);
+ }
+ SirenixEditorGUI.EndListItem();
+ }
+ }
+ SirenixEditorGUI.EndVerticalList();
+ GUIHelper.PopGUIEnabled();
+ }
+ SirenixEditorGUI.EndFadeGroup();
+ }
+ }
+}
+
+#endif // UNITY_EDITOR && !UNITY_2019_1_OR_NEWER
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncListDrawer.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncListDrawer.cs.meta new file mode 100644 index 00000000..7db195d1 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncListDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 047c7e4af9c032a428c12b7c564a6593
+timeCreated: 1545410615
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncVarAttributeDrawer.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncVarAttributeDrawer.cs new file mode 100644 index 00000000..02d7d1d9 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncVarAttributeDrawer.cs @@ -0,0 +1,42 @@ +//-----------------------------------------------------------------------
+// <copyright file="SyncVarAttributeDrawer.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+#if UNITY_EDITOR && !UNITY_2019_1_OR_NEWER
+#pragma warning disable 0618
+
+namespace Sirenix.OdinInspector.Editor.Drawers
+{
+ using Sirenix.Utilities;
+ using UnityEditor;
+ using UnityEngine;
+ using UnityEngine.Networking;
+
+ /// <summary>
+ /// SyncVar attribute drawer.
+ /// </summary>
+ public class SyncVarAttributeDrawer : OdinAttributeDrawer<SyncVarAttribute>
+ {
+ /// <summary>
+ /// Draws the property.
+ /// </summary>
+ protected override void DrawPropertyLayout(GUIContent label)
+ {
+ GUILayout.BeginHorizontal();
+ {
+ GUILayout.BeginVertical();
+ {
+ this.CallNextDrawer(label);
+ }
+ GUILayout.EndVertical();
+
+ GUILayout.Label("SyncVar", EditorStyles.miniLabel, GUILayoutOptions.Width(52f));
+ }
+ GUILayout.EndHorizontal();
+ }
+ }
+}
+
+#endif // UNITY_EDITOR && !UNITY_2019_1_OR_NEWER
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncVarAttributeDrawer.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncVarAttributeDrawer.cs.meta new file mode 100644 index 00000000..14f30448 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/SyncVarAttributeDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: bda5b631304c8cb4485d60ef8bda618b
+timeCreated: 1545410615
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Vector2IntMinMaxAttributeDrawer.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Vector2IntMinMaxAttributeDrawer.cs new file mode 100644 index 00000000..f70613f9 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Vector2IntMinMaxAttributeDrawer.cs @@ -0,0 +1,73 @@ +//-----------------------------------------------------------------------
+// <copyright file="Vector2IntMinMaxAttributeDrawer.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER
+
+namespace Sirenix.OdinInspector.Editor.Drawers
+{
+ using Sirenix.OdinInspector;
+ using Sirenix.OdinInspector.Editor;
+ using Sirenix.OdinInspector.Editor.ValueResolvers;
+ using Sirenix.Utilities;
+ using Sirenix.Utilities.Editor;
+ using System.Reflection;
+ using UnityEditor;
+ using UnityEngine;
+
+ /// <summary>
+ /// Draws Vector2Int properties marked with <see cref="MinMaxSliderAttribute"/>.
+ /// </summary>
+ public class Vector2IntMinMaxAttributeDrawer : OdinAttributeDrawer<MinMaxSliderAttribute, Vector2Int>
+ {
+ private ValueResolver<float> minGetter;
+ private ValueResolver<float> maxGetter;
+ private ValueResolver<Vector2Int> vector2IntMinMaxGetter;
+
+ /// <summary>
+ /// Initializes the drawer by resolving any optional references to members for min/max value.
+ /// </summary>
+ protected override void Initialize()
+ {
+ // Min member reference.
+ this.minGetter = ValueResolver.Get<float>(this.Property, this.Attribute.MinValueGetter, this.Attribute.MinValue);
+ this.maxGetter = ValueResolver.Get<float>(this.Property, this.Attribute.MaxValueGetter, this.Attribute.MaxValue);
+
+ // Min max member reference.
+ if (this.Attribute.MinMaxValueGetter != null)
+ {
+ this.vector2IntMinMaxGetter = ValueResolver.Get<Vector2Int>(this.Property, this.Attribute.MinMaxValueGetter);
+ }
+ }
+
+ /// <summary>
+ /// Draws the property.
+ /// </summary>
+ protected override void DrawPropertyLayout(GUIContent label)
+ {
+ ValueResolver.DrawErrors(this.minGetter, this.maxGetter, this.vector2IntMinMaxGetter);
+
+ // Get the range of the slider from the attribute or from member references.
+ Vector2 range;
+ if (this.vector2IntMinMaxGetter != null && !this.vector2IntMinMaxGetter.HasError)
+ {
+ range = (Vector2)this.vector2IntMinMaxGetter.GetValue();
+ }
+ else
+ {
+ range.x = this.minGetter.GetValue();
+ range.y = this.maxGetter.GetValue();
+ }
+
+ EditorGUI.BeginChangeCheck();
+ Vector2 value = SirenixEditorFields.MinMaxSlider(label, (Vector2)this.ValueEntry.SmartValue, range, this.Attribute.ShowFields);
+ if (EditorGUI.EndChangeCheck())
+ {
+ this.ValueEntry.SmartValue = new Vector2Int((int)value.x, (int)value.y);
+ }
+ }
+ }
+}
+#endif // UNITY_EDITOR && UNITY_2017_2_OR_NEWER
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Vector2IntMinMaxAttributeDrawer.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Vector2IntMinMaxAttributeDrawer.cs.meta new file mode 100644 index 00000000..84869a73 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/Vector2IntMinMaxAttributeDrawer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 30393ed590c8fb64da0612e8a2fad8a4
+timeCreated: 1532688697
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntDrawers.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntDrawers.cs new file mode 100644 index 00000000..c7300fbc --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntDrawers.cs @@ -0,0 +1,141 @@ +//-----------------------------------------------------------------------
+// <copyright file="VectorIntDrawers.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER
+
+namespace Sirenix.OdinInspector.Editor.Drawers
+{
+ using Utilities.Editor;
+ using UnityEditor;
+ using UnityEngine;
+
+ /// <summary>
+ /// Vector2Int proprety drawer.
+ /// </summary>
+ public sealed class Vector2IntDrawer : OdinValueDrawer<Vector2Int>, IDefinesGenericMenuItems
+ {
+ /// <summary>
+ /// Draws the property.
+ /// </summary>
+ protected override void DrawPropertyLayout(GUIContent label)
+ {
+ Rect labelRect;
+ var contentRect = SirenixEditorGUI.BeginHorizontalPropertyLayout(label, out labelRect);
+ {
+ EditorGUI.BeginChangeCheck();
+ var val = SirenixEditorFields.VectorPrefixSlideRect(labelRect, (Vector2)this.ValueEntry.SmartValue);
+ if (EditorGUI.EndChangeCheck())
+ {
+ this.ValueEntry.SmartValue = new Vector2Int((int)val.x, (int)val.y);
+ }
+
+ var showLabels = SirenixEditorFields.ResponsiveVectorComponentFields && contentRect.width >= 185;
+ GUIHelper.PushLabelWidth(SirenixEditorFields.SingleLetterStructLabelWidth);
+ this.ValueEntry.Property.Children[0].Draw(showLabels ? GUIHelper.TempContent("X") : null);
+ this.ValueEntry.Property.Children[1].Draw(showLabels ? GUIHelper.TempContent("Y") : null);
+ GUIHelper.PopLabelWidth();
+
+ }
+ SirenixEditorGUI.EndHorizontalPropertyLayout();
+ }
+
+ /// <summary>
+ /// Populates the generic menu for the property.
+ /// </summary>
+ public void PopulateGenericMenu(InspectorProperty property, GenericMenu genericMenu)
+ {
+ Vector2Int value = (Vector2Int)property.ValueEntry.WeakSmartValue;
+
+ if (genericMenu.GetItemCount() > 0)
+ {
+ genericMenu.AddSeparator("");
+ }
+ genericMenu.AddItem(new GUIContent("Zero", "Set the vector to (0, 0)"), value == Vector2Int.zero, () => SetVector(property, Vector2Int.zero));
+ genericMenu.AddItem(new GUIContent("One", "Set the vector to (1, 1)"), value == Vector2Int.one, () => SetVector(property, Vector2Int.one));
+ genericMenu.AddSeparator("");
+ genericMenu.AddItem(new GUIContent("Right", "Set the vector to (1, 0)"), value == Vector2Int.right, () => SetVector(property, Vector2Int.right));
+ genericMenu.AddItem(new GUIContent("Left", "Set the vector to (-1, 0)"), value == Vector2Int.left, () => SetVector(property, Vector2Int.left));
+ genericMenu.AddItem(new GUIContent("Up", "Set the vector to (0, 1)"), value == Vector2Int.up, () => SetVector(property, Vector2Int.up));
+ genericMenu.AddItem(new GUIContent("Down", "Set the vector to (0, -1)"), value == Vector2Int.down, () => SetVector(property, Vector2Int.down));
+ }
+
+ private void SetVector(InspectorProperty property, Vector2Int value)
+ {
+ property.Tree.DelayActionUntilRepaint(() =>
+ {
+ for (int i = 0; i < property.ValueEntry.ValueCount; i++)
+ {
+ property.ValueEntry.WeakValues[i] = value;
+ }
+ });
+ }
+ }
+
+ /// <summary>
+ /// Vector3Int property drawer.
+ /// </summary>
+ public sealed class Vector3IntDrawer : OdinValueDrawer<Vector3Int>, IDefinesGenericMenuItems
+ {
+ /// <summary>
+ /// Draws the property.
+ /// </summary>
+ protected override void DrawPropertyLayout(GUIContent label)
+ {
+ Rect labelRect;
+ var contentRect = SirenixEditorGUI.BeginHorizontalPropertyLayout(label, out labelRect);
+ {
+ EditorGUI.BeginChangeCheck();
+ var val = SirenixEditorFields.VectorPrefixSlideRect(labelRect, (Vector3)this.ValueEntry.SmartValue);
+ if (EditorGUI.EndChangeCheck())
+ {
+ this.ValueEntry.SmartValue = new Vector3Int((int)val.x, (int)val.y, (int)val.z);
+ }
+
+ var showLabels = SirenixEditorFields.ResponsiveVectorComponentFields && contentRect.width >= 185;
+ GUIHelper.PushLabelWidth(SirenixEditorFields.SingleLetterStructLabelWidth);
+ this.ValueEntry.Property.Children[0].Draw(showLabels ? GUIHelper.TempContent("X") : null);
+ this.ValueEntry.Property.Children[1].Draw(showLabels ? GUIHelper.TempContent("Y") : null);
+ this.ValueEntry.Property.Children[2].Draw(showLabels ? GUIHelper.TempContent("Z") : null);
+ GUIHelper.PopLabelWidth();
+
+ }
+ SirenixEditorGUI.EndHorizontalPropertyLayout();
+ }
+
+ /// <summary>
+ /// Populates the generic menu for the property.
+ /// </summary>
+ public void PopulateGenericMenu(InspectorProperty property, GenericMenu genericMenu)
+ {
+ Vector3Int value = (Vector3Int)property.ValueEntry.WeakSmartValue;
+
+ if (genericMenu.GetItemCount() > 0)
+ {
+ genericMenu.AddSeparator("");
+ }
+
+ genericMenu.AddItem(new GUIContent("Zero", "Set the vector to (0, 0, 0)"), value == Vector3Int.zero, () => SetVector(property, Vector3Int.zero));
+ genericMenu.AddItem(new GUIContent("One", "Set the vector to (1, 1, 1)"), value == Vector3Int.one, () => SetVector(property, Vector3Int.one));
+ genericMenu.AddSeparator("");
+ genericMenu.AddItem(new GUIContent("Right", "Set the vector to (1, 0, 0)"), value == Vector3Int.right, () => SetVector(property, Vector3Int.right));
+ genericMenu.AddItem(new GUIContent("Left", "Set the vector to (-1, 0, 0)"), value == Vector3Int.left, () => SetVector(property, Vector3Int.left));
+ genericMenu.AddItem(new GUIContent("Up", "Set the vector to (0, 1, 0)"), value == Vector3Int.up, () => SetVector(property, Vector3Int.up));
+ genericMenu.AddItem(new GUIContent("Down", "Set the vector to (0, -1, 0)"), value == Vector3Int.down, () => SetVector(property, Vector3Int.down));
+ genericMenu.AddItem(new GUIContent("Forward", "Set the vector property to (0, 0, 1)"), value == new Vector3Int(0, 0, 1), () => SetVector(property, new Vector3Int(0, 0, 1)));
+ genericMenu.AddItem(new GUIContent("Back", "Set the vector property to (0, 0, -1)"), value == new Vector3Int(0, 0, -1), () => SetVector(property, new Vector3Int(0, 0, -1)));
+ }
+
+ private void SetVector(InspectorProperty property, Vector3Int value)
+ {
+ property.Tree.DelayActionUntilRepaint(() =>
+ {
+ property.ValueEntry.WeakSmartValue = value;
+ });
+ }
+ }
+}
+
+#endif // UNITY_EDITOR && UNITY_2017_2_OR_NEWER
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntDrawers.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntDrawers.cs.meta new file mode 100644 index 00000000..5e47f131 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntDrawers.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 2fc48d59edff00f49b8ae717c776ff45
+timeCreated: 1520596090
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntPropertyResolvers.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntPropertyResolvers.cs new file mode 100644 index 00000000..2e7df3e0 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntPropertyResolvers.cs @@ -0,0 +1,54 @@ +//-----------------------------------------------------------------------
+// <copyright file="VectorIntPropertyResolvers.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER
+
+namespace Sirenix.OdinInspector.Editor.Drawers
+{
+ using UnityEngine;
+
+ public sealed class Vector2IntResolver : BaseMemberPropertyResolver<Vector2Int>
+ {
+ protected override InspectorPropertyInfo[] GetPropertyInfos()
+ {
+ return new InspectorPropertyInfo[]
+ {
+ InspectorPropertyInfo.CreateValue("x", 0, this.Property.ValueEntry.SerializationBackend,
+ new GetterSetter<Vector2Int, int>(
+ getter: (ref Vector2Int vec) => vec.x,
+ setter: (ref Vector2Int vec, int value) => vec.x = value)),
+ InspectorPropertyInfo.CreateValue("y", 0, this.Property.ValueEntry.SerializationBackend,
+ new GetterSetter<Vector2Int, int>(
+ getter: (ref Vector2Int vec) => vec.y,
+ setter: (ref Vector2Int vec, int value) => vec.y = value)),
+ };
+ }
+ }
+
+ public sealed class Vector3IntResolver : BaseMemberPropertyResolver<Vector3Int>
+ {
+ protected override InspectorPropertyInfo[] GetPropertyInfos()
+ {
+ return new InspectorPropertyInfo[]
+ {
+ InspectorPropertyInfo.CreateValue("x", 0, this.Property.ValueEntry.SerializationBackend,
+ new GetterSetter<Vector3Int, int>(
+ getter: (ref Vector3Int vec) => vec.x,
+ setter: (ref Vector3Int vec, int value) => vec.x = value)),
+ InspectorPropertyInfo.CreateValue("y", 0, this.Property.ValueEntry.SerializationBackend,
+ new GetterSetter<Vector3Int, int>(
+ getter: (ref Vector3Int vec) => vec.y,
+ setter: (ref Vector3Int vec, int value) => vec.y = value)),
+ InspectorPropertyInfo.CreateValue("z", 0, this.Property.ValueEntry.SerializationBackend,
+ new GetterSetter<Vector3Int, int>(
+ getter: (ref Vector3Int vec) => vec.z,
+ setter: (ref Vector3Int vec, int value) => vec.z = value)),
+ };
+ }
+ }
+}
+
+#endif // UNITY_EDITOR && UNITY_2017_2_OR_NEWER
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntPropertyResolvers.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntPropertyResolvers.cs.meta new file mode 100644 index 00000000..07a849b8 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Editor/VectorIntPropertyResolvers.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 435323e396d85494daeb5278528fe138
+timeCreated: 1539340561
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/SerializedNetworkBehaviour.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/SerializedNetworkBehaviour.cs new file mode 100644 index 00000000..7362d62e --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/SerializedNetworkBehaviour.cs @@ -0,0 +1,66 @@ +//-----------------------------------------------------------------------
+// <copyright file="SerializedNetworkBehaviour.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+#if !UNITY_2019_1_OR_NEWER
+#pragma warning disable 0618
+
+namespace Sirenix.OdinInspector
+{
+ using Sirenix.Serialization;
+ using UnityEngine;
+ using UnityEngine.Networking;
+
+ /// <summary>
+ /// A Unity NetworkBehaviour which is serialized by the Sirenix serialization system.
+ /// Please note that Odin's custom serialization only works for non-synced variables - [SyncVar] and SyncLists still have the same limitations.
+ /// </summary>
+ [ShowOdinSerializedPropertiesInInspector]
+ public abstract class SerializedNetworkBehaviour : NetworkBehaviour, ISerializationCallbackReceiver, ISupportsPrefabSerialization
+ {
+ [SerializeField, HideInInspector]
+ private SerializationData serializationData;
+
+ SerializationData ISupportsPrefabSerialization.SerializationData { get { return this.serializationData; } set { this.serializationData = value; } }
+
+ void ISerializationCallbackReceiver.OnAfterDeserialize()
+ {
+ UnitySerializationUtility.DeserializeUnityObject(this, ref this.serializationData);
+ this.OnAfterDeserialize();
+ }
+
+ void ISerializationCallbackReceiver.OnBeforeSerialize()
+ {
+ UnitySerializationUtility.SerializeUnityObject(this, ref this.serializationData);
+ this.OnBeforeSerialize();
+ }
+
+ /// <summary>
+ /// Invoked after deserialization has taken place.
+ /// </summary>
+ protected virtual void OnAfterDeserialize()
+ {
+ }
+
+ /// <summary>
+ /// Invoked before serialization has taken place.
+ /// </summary>
+ protected virtual void OnBeforeSerialize()
+ {
+ }
+
+#if UNITY_EDITOR
+
+ [HideInTables]
+ [OnInspectorGUI, PropertyOrder(int.MinValue)]
+ private void InternalOnInspectorGUI()
+ {
+ EditorOnlyModeConfigUtility.InternalOnInspectorGUI(this);
+ }
+
+#endif
+ }
+}
+
+#endif // UNITY_2019_1_OR_NEWER
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/SerializedNetworkBehaviour.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/SerializedNetworkBehaviour.cs.meta new file mode 100644 index 00000000..b935e798 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/SerializedNetworkBehaviour.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: 5d496f720527c984b8acc75a238bbd79
+timeCreated: 1545412221
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Sirenix.OdinInspector.CompatibilityLayer.asmdef b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Sirenix.OdinInspector.CompatibilityLayer.asmdef new file mode 100644 index 00000000..0d791682 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Sirenix.OdinInspector.CompatibilityLayer.asmdef @@ -0,0 +1,11 @@ +{ + "name": "Sirenix.OdinInspector.CompatibilityLayer", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": true, + "autoReferenced": true, + "overrideReferences": false, + "precompiledReferences": [], + "defineConstraints": [] +}
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Sirenix.OdinInspector.CompatibilityLayer.asmdef.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Sirenix.OdinInspector.CompatibilityLayer.asmdef.meta new file mode 100644 index 00000000..af257961 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/Sirenix.OdinInspector.CompatibilityLayer.asmdef.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1e42d975e06bb1646a960c7c31728951 +timeCreated: 1602076732 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs new file mode 100644 index 00000000..ccb62ce0 --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs @@ -0,0 +1,80 @@ +#if UNITY_2017_2_OR_NEWER
+
+//-----------------------------------------------------------------------
+// <copyright file="VectorIntFormatters.cs" company="Sirenix IVS">
+// Copyright (c) Sirenix IVS. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+[assembly: Sirenix.Serialization.RegisterFormatter(typeof(Sirenix.Serialization.Vector2IntFormatter))]
+[assembly: Sirenix.Serialization.RegisterFormatter(typeof(Sirenix.Serialization.Vector3IntFormatter))]
+namespace Sirenix.Serialization
+{
+ using UnityEngine;
+
+ /// <summary>
+ /// Custom formatter for the <see cref="Vector2Int"/> type.
+ /// </summary>
+ /// <seealso cref="Sirenix.Serialization.MinimalBaseFormatter{UnityEngine.Vector2Int}" />
+ public class Vector2IntFormatter : MinimalBaseFormatter<Vector2Int>
+ {
+ private static readonly Serializer<int> Serializer = Serialization.Serializer.Get<int>();
+
+ /// <summary>
+ /// Reads into the specified value using the specified reader.
+ /// </summary>
+ /// <param name="value">The value to read into.</param>
+ /// <param name="reader">The reader to use.</param>
+ protected override void Read(ref Vector2Int value, IDataReader reader)
+ {
+ value.x = Vector2IntFormatter.Serializer.ReadValue(reader);
+ value.y = Vector2IntFormatter.Serializer.ReadValue(reader);
+ }
+
+ /// <summary>
+ /// Writes from the specified value using the specified writer.
+ /// </summary>
+ /// <param name="value">The value to write from.</param>
+ /// <param name="writer">The writer to use.</param>
+ protected override void Write(ref Vector2Int value, IDataWriter writer)
+ {
+ Vector2IntFormatter.Serializer.WriteValue(value.x, writer);
+ Vector2IntFormatter.Serializer.WriteValue(value.y, writer);
+ }
+ }
+
+ /// <summary>
+ /// Custom formatter for the <see cref="Vector3Int"/> type.
+ /// </summary>
+ /// <seealso cref="Sirenix.Serialization.MinimalBaseFormatter{UnityEngine.Vector3Int}" />
+ public class Vector3IntFormatter : MinimalBaseFormatter<Vector3Int>
+ {
+ private static readonly Serializer<int> Serializer = Serialization.Serializer.Get<int>();
+
+ /// <summary>
+ /// Reads into the specified value using the specified reader.
+ /// </summary>
+ /// <param name="value">The value to read into.</param>
+ /// <param name="reader">The reader to use.</param>
+ protected override void Read(ref Vector3Int value, IDataReader reader)
+ {
+ value.x = Vector3IntFormatter.Serializer.ReadValue(reader);
+ value.y = Vector3IntFormatter.Serializer.ReadValue(reader);
+ value.z = Vector3IntFormatter.Serializer.ReadValue(reader);
+ }
+
+ /// <summary>
+ /// Writes from the specified value using the specified writer.
+ /// </summary>
+ /// <param name="value">The value to write from.</param>
+ /// <param name="writer">The writer to use.</param>
+ protected override void Write(ref Vector3Int value, IDataWriter writer)
+ {
+ Vector3IntFormatter.Serializer.WriteValue(value.x, writer);
+ Vector3IntFormatter.Serializer.WriteValue(value.y, writer);
+ Vector3IntFormatter.Serializer.WriteValue(value.z, writer);
+ }
+ }
+}
+
+#endif
\ No newline at end of file diff --git a/Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs.meta b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs.meta new file mode 100644 index 00000000..a30d06af --- /dev/null +++ b/Assets/Plugins/Sirenix/Odin Inspector/Scripts/VectorIntFormatters.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2
+guid: a2f1c424a60dfbd4fa331449baeac351
+timeCreated: 1520596090
+licenseType: Store
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
|