This commit is contained in:
2026-06-16 16:57:07 +07:00
parent 26a21f63bb
commit 6880c4724e
198 changed files with 168 additions and 69 deletions

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f61850bb111c02e46b895c9950bf09a8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,26 +0,0 @@
#if UNITY_EDITOR
namespace Sirenix.OdinInspector.Demos
{
using UnityEditor;
using Sirenix.OdinInspector.Editor;
using Sirenix.OdinInspector;
using Sirenix.Utilities.Editor;
using Sirenix.Utilities;
public class BasicOdinEditorExampleWindow : OdinEditorWindow
{
[MenuItem("Tools/Odin/Demos/Odin Editor Window Demos/Basic Odin Editor Window")]
private static void OpenWindow()
{
var window = GetWindow<BasicOdinEditorExampleWindow>();
// Nifty little trick to quickly position the window in the middle of the editor.
window.position = GUIHelper.GetEditorWindowRect().AlignCenter(700, 700);
}
[EnumToggleButtons]
[InfoBox("Inherit from OdinEditorWindow instead of EditorWindow in order to create editor windows like you would inspectors - by exposing members and using attributes.")]
public ViewTool SomeField;
}
}
#endif

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 9a1e435d912810b4890a5ca4682f0e0f
timeCreated: 1514982238
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,60 +0,0 @@
#if UNITY_EDITOR
namespace Sirenix.OdinInspector.Demos
{
using Sirenix.OdinInspector.Editor;
using System.Linq;
using UnityEngine;
using Sirenix.Utilities.Editor;
using Sirenix.Serialization;
using UnityEditor;
using Sirenix.Utilities;
//
// Be sure to check out OdinMenuStyleExample.cs as well. It shows you various ways to customize the look and behaviour of OdinMenuTrees.
//
public class OdinMenuEditorWindowExample : OdinMenuEditorWindow
{
[MenuItem("Tools/Odin/Demos/Odin Editor Window Demos/Odin Menu Editor Window Example")]
private static void OpenWindow()
{
var window = GetWindow<OdinMenuEditorWindowExample>();
window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 600);
}
[SerializeField]
private SomeData someData = new SomeData(); // Take a look at SomeData.cs to see how serialization works in Editor Windows.
protected override OdinMenuTree BuildMenuTree()
{
OdinMenuTree tree = new OdinMenuTree(supportsMultiSelect: true)
{
{ "Home", this, EditorIcons.House }, // Draws the this.someData field in this case.
{ "Odin Settings", null, SdfIconType.GearFill },
{ "Odin Settings/Color Palettes", ColorPaletteManager.Instance, SdfIconType.PaletteFill },
{ "Odin Settings/AOT Generation", AOTGenerationConfig.Instance, EditorIcons.SmartPhone },
{ "Player Settings", Resources.FindObjectsOfTypeAll<PlayerSettings>().FirstOrDefault() },
{ "Some Class", this.someData }
};
tree.AddAllAssetsAtPath("Odin Settings/More Odin Settings", "Plugins/Sirenix", typeof(ScriptableObject), true)
.AddThumbnailIcons();
tree.AddAssetAtPath("Odin Getting Started", "Plugins/Sirenix/Getting Started With Odin.asset");
tree.MenuItems.Insert(2, new OdinMenuItem(tree, "Menu Style", tree.DefaultMenuStyle));
tree.Add("Menu/Items/Are/Created/As/Needed", new GUIContent());
tree.Add("Menu/Items/Are/Created", new GUIContent("And can be overridden"));
tree.SortMenuItemsByName();
// As you can see, Odin provides a few ways to quickly add editors / objects to your menu tree.
// The API also gives you full control over the selection, etc..
// Make sure to check out the API Documentation for OdinMenuEditorWindow, OdinMenuTree and OdinMenuItem for more information on what you can do!
return tree;
}
}
}
#endif

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 66093819dfa2a0e49a76dae21d7c8a4c
timeCreated: 1515335602
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,117 +0,0 @@
#if UNITY_EDITOR
namespace Sirenix.OdinInspector.Demos
{
using Sirenix.OdinInspector.Editor;
using UnityEngine;
using UnityEditor;
using System.Linq;
using Sirenix.Utilities;
using System.Collections.Generic;
using Sirenix.Utilities.Editor;
public class OdinMenuStyleExample : OdinMenuEditorWindow
{
[MenuItem("Tools/Odin/Demos/Odin Editor Window Demos/Odin Menu Style Example")]
private static void OpenWindow()
{
var window = GetWindow<OdinMenuStyleExample>();
window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 600);
}
protected override OdinMenuTree BuildMenuTree()
{
var tree = new OdinMenuTree(true);
var customMenuStyle = new OdinMenuStyle
{
BorderPadding = 0f,
AlignTriangleLeft = true,
TriangleSize = 16f,
TrianglePadding = 0f,
Offset = 20f,
Height = 23,
IconPadding = 0f,
BorderAlpha = 0.323f
};
tree.DefaultMenuStyle = customMenuStyle;
tree.Config.DrawSearchToolbar = true;
// Adds the custom menu style to the tree, so that you can play around with it.
// Once you are happy, you can press Copy C# Snippet copy its settings and paste it in code.
// And remove the "Menu Style" menu item from the tree.
tree.AddObjectAtPath("Menu Style", customMenuStyle);
for (int i = 0; i < 5; i++)
{
var customObject = new SomeCustomClass() { Name = i.ToString() };
var customMenuItem = new MyCustomMenuItem(tree, customObject);
tree.AddMenuItemAtPath("Custom Menu Items", customMenuItem);
}
tree.AddAllAssetsAtPath("Scriptable Objects in Plugins Tree", "Plugins", typeof(ScriptableObject), true, false);
tree.AddAllAssetsAtPath("Scriptable Objects in Plugins Flat", "Plugins", typeof(ScriptableObject), true, true);
tree.AddAllAssetsAtPath("Only Configs has Icons", "Plugins/Sirenix", true, false);
tree.EnumerateTree()
.AddThumbnailIcons()
.SortMenuItemsByName();
return tree;
}
//// The editor window itself can also be customized.
//protected override void OnEnable()
//{
// base.OnEnable();
// this.MenuWidth = 200;
// this.ResizableMenuWidth = true;
// this.WindowPadding = new Vector4(10, 10, 10, 10);
// this.DrawUnityEditorPreview = true;
// this.DefaultEditorPreviewHeight = 20;
// this.UseScrollView = true;
//}
private class MyCustomMenuItem : OdinMenuItem
{
private readonly SomeCustomClass instance;
public MyCustomMenuItem(OdinMenuTree tree, SomeCustomClass instance) : base(tree, instance.Name, instance)
{
this.instance = instance;
}
protected override void OnDrawMenuItem(Rect rect, Rect labelRect)
{
labelRect.x -= 16;
this.instance.Enabled = GUI.Toggle(labelRect.AlignMiddle(18).AlignLeft(16), this.instance.Enabled, GUIContent.none);
// Toggle selection when pressing space.
if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Space)
{
var selection = this.MenuTree.Selection
.Select(x => x.Value)
.OfType<SomeCustomClass>();
if (selection.Any())
{
var enabled = !selection.FirstOrDefault().Enabled;
selection.ForEach(x => x.Enabled = enabled);
Event.current.Use();
}
}
}
public override string SmartName { get { return this.instance.Name; } }
}
private class SomeCustomClass
{
public bool Enabled = true;
public string Name;
}
}
}
#endif

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: e18d6c02692f0604f84f93cb250834f1
timeCreated: 1515762718
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,63 +0,0 @@
#if UNITY_EDITOR
namespace Sirenix.OdinInspector.Demos
{
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities.Editor;
using Sirenix.OdinInspector;
using Sirenix.Utilities;
public class OverrideGetTargetsExampleWindow : OdinEditorWindow
{
[MenuItem("Tools/Odin/Demos/Odin Editor Window Demos/Draw Any Target")]
private static void OpenWindow()
{
GetWindow<OverrideGetTargetsExampleWindow>()
.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 600);
}
[HideLabel]
[Multiline(6)]
[SuffixLabel("This is drawn", true)]
public string Test;
// In the default implemenentation, it simply yield returns it self.
// But you can also override this behaviour and have your window render any
// object you like - Unity and non-Unity objects a like.
protected override IEnumerable<object> GetTargets()
{
// Draws this instance using Odin
yield return this;
// Draw non-unity objects.
yield return GUI.skin.settings; // GUISettings is a regular class.
// Or Unity objects.
yield return GUI.skin; // GUI.Skin is a ScriptableObject
}
// You can also override the method that draws each editor.
// This come in handy if you want to add titles, boxes, or draw them in a GUI.Window etc...
protected override void DrawEditor(int index)
{
var currentDrawingEditor = this.CurrentDrawingTargets[index];
SirenixEditorGUI.Title(
title: currentDrawingEditor.ToString(),
subtitle: currentDrawingEditor.GetType().GetNiceFullName(),
textAlignment: TextAlignment.Left,
horizontalLine: true
);
base.DrawEditor(index);
if (index != this.CurrentDrawingTargets.Count - 1)
{
SirenixEditorGUI.DrawThickHorizontalSeparator(15, 15);
}
}
}
}
#endif

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 5957605b5da2ea642a9d9037f88d3627
timeCreated: 1514982238
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,64 +0,0 @@
#if UNITY_EDITOR
namespace Sirenix.OdinInspector.Demos
{
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities;
using Sirenix.Utilities.Editor;
using UnityEngine;
public class SomeClass2
{
[HideLabel, Title("Title", horizontalLine: false, bold: false)]
public string Title = "Some Title";
[TextArea(10, 20)]
public string Description = "Some description.";
}
public class QuicklyInspectObjects
{
private SomeClass2 someObject = new SomeClass2();
[Button(ButtonSizes.Large)]
[Title("OdinEditorWindow.InspectObject examples", "Make sure to checkout QuicklyInspectObjects.cs")]
private void InspectObject()
{
OdinEditorWindow.InspectObject(this.someObject);
}
[Button(ButtonSizes.Large), HorizontalGroup("row1")]
private void InDropDownAutoHeight()
{
var btnRect = GUIHelper.GetCurrentLayoutRect();
OdinEditorWindow.InspectObjectInDropDown(this.someObject, btnRect, btnRect.width);
}
[Button(ButtonSizes.Large), HorizontalGroup("row1")]
private void InDropDown()
{
var btnRect = GUIHelper.GetCurrentLayoutRect();
OdinEditorWindow.InspectObjectInDropDown(this.someObject, btnRect, new Vector2(btnRect.width, 100));
}
[Button(ButtonSizes.Large), HorizontalGroup("row2")]
private void InCenter()
{
var window = OdinEditorWindow.InspectObject(this.someObject);
window.position = GUIHelper.GetEditorWindowRect().AlignCenter(270, 200);
}
[Button(ButtonSizes.Large), HorizontalGroup("row2")]
private void OtherStuffYouCanDo()
{
var window = OdinEditorWindow.InspectObject(this.someObject);
window.position = GUIHelper.GetEditorWindowRect().AlignCenter(270, 200);
window.titleContent = new GUIContent("Custom title", EditorIcons.RulerRect.Active);
window.OnClose += () => Debug.Log("Window Closed");
window.OnBeginGUI += () => GUILayout.Label("-----------");
window.OnEndGUI += () => GUILayout.Label("-----------");
}
}
}
#endif

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 503c8a9f7cfad80439b12cb7464b21e4
timeCreated: 1515088606
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,33 +0,0 @@
#if UNITY_EDITOR
namespace Sirenix.OdinInspector.Demos
{
using UnityEditor;
using System;
[HideLabel]
[Serializable]
public class SomeData
{
[MultiLineProperty(3), Title("Basic Odin Menu Editor Window", "Inherit from OdinMenuEditorWindow, and build your menu tree")]
public string Test1 = "This value is persistent cross reloads, but will reset once you restart Unity or close the window.";
[MultiLineProperty(3), ShowInInspector, NonSerialized]
public string Test2 = "This value is not persistent cross reloads, and will reset once you hit play or recompile.";
[MultiLineProperty(3), ShowInInspector]
private string Test3
{
get
{
return EditorPrefs.GetString("OdinDemo.PersistentString",
"This value is persistent forever, even cross Unity projects. But it's not saved together " +
"with your project. That's where ScriptableObejcts and OdinEditorWindows come in handy.");
}
set
{
EditorPrefs.SetString("OdinDemo.PersistentString", value);
}
}
}
}
#endif

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 23d6e50778fcc414388c45efaf3da20f
timeCreated: 1516273612
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,48 +0,0 @@
#if UNITY_EDITOR
namespace Sirenix.OdinInspector.Demos
{
using UnityEngine;
using UnityEditor;
using Sirenix.OdinInspector.Editor;
using Sirenix.OdinInspector;
using Sirenix.Utilities.Editor;
using Sirenix.Utilities;
public class SomeTextureToolWindow : OdinEditorWindow
{
[MenuItem("Tools/Odin/Demos/Odin Editor Window Demos/Some Texture Tool")]
private static void OpenWindow()
{
var window = GetWindow<SomeTextureToolWindow>();
window.position = GUIHelper.GetEditorWindowRect().AlignCenter(600, 600);
window.titleContent = new GUIContent("Some Texture Tool Window");
}
[BoxGroup("Settings")]
[FolderPath(RequireExistingPath = true)]
public string OutputPath
{
// Use EditorPrefs to hold persisntent user-variables.
get { return EditorPrefs.GetString("SomeTextureToolWindow.OutputPath"); }
set { EditorPrefs.SetString("SomeTextureToolWindow.OutputPath", value); }
}
[EnumToggleButtons]
[BoxGroup("Settings")]
public ScaleMode ScaleMode;
[HorizontalGroup(0.5f, PaddingRight = 5, LabelWidth = 70)]
public Texture[] Textures = new Texture[8];
[ReadOnly]
[HorizontalGroup]
[InlineEditor(InlineEditorModes.LargePreview)]
public Texture Preview;
[Button(ButtonSizes.Gigantic), GUIColor(0, 1, 0)]
public void PerformSomeAction()
{
}
}
}
#endif

View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 2a14e003cbbbc8446aace397291feeae
timeCreated: 1514333524
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: