mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 00:08:51 -05:00
Add samples window - Tools/Tri Inspector/Samples
This commit is contained in:
parent
46109e5520
commit
2ee3ed2fb7
8
Editor.Samples.meta
Normal file
8
Editor.Samples.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0e88f221fc25564eb4caf4d374bab5b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
3
Editor.Samples/Buttons.meta
Normal file
3
Editor.Samples/Buttons.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1068a85eb61646efb6cffc2680cf0be3
|
||||
timeCreated: 1656857100
|
11
Editor.Samples/Buttons/Buttons_ButtonSample.cs
Normal file
11
Editor.Samples/Buttons/Buttons_ButtonSample.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Buttons_ButtonSample : ScriptableObject
|
||||
{
|
||||
[Button("Click me!")]
|
||||
private void DoButton()
|
||||
{
|
||||
Debug.Log("Button clicked!");
|
||||
}
|
||||
}
|
3
Editor.Samples/Buttons/Buttons_ButtonSample.cs.meta
Normal file
3
Editor.Samples/Buttons/Buttons_ButtonSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfc765523b0944faa880f75c257dc865
|
||||
timeCreated: 1656857108
|
25
Editor.Samples/Buttons/Buttons_EnumToggleButtonsSample.cs
Normal file
25
Editor.Samples/Buttons/Buttons_EnumToggleButtonsSample.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Buttons_EnumToggleButtonsSample : ScriptableObject
|
||||
{
|
||||
[EnumToggleButtons] public SomeEnum someEnum;
|
||||
[EnumToggleButtons] public SomeFlags someFlags;
|
||||
|
||||
public enum SomeEnum
|
||||
{
|
||||
One,
|
||||
Two,
|
||||
Three
|
||||
}
|
||||
|
||||
[Flags] public enum SomeFlags
|
||||
{
|
||||
A = 1 << 0,
|
||||
B = 1 << 1,
|
||||
C = 1 << 2,
|
||||
AB = A | B,
|
||||
BC = B | C,
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5287edf013a41608e8082a8766f1f1a
|
||||
timeCreated: 1656857128
|
3
Editor.Samples/Collections.meta
Normal file
3
Editor.Samples/Collections.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f188dac8f6fb4d7cb4251a6d0a3469a9
|
||||
timeCreated: 1656855659
|
@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Collections_ListDrawerSettingsSample : ScriptableObject
|
||||
{
|
||||
[ListDrawerSettings(Draggable = true,
|
||||
HideAddButton = false,
|
||||
HideRemoveButton = false,
|
||||
AlwaysExpanded = false)]
|
||||
public List<Material> list;
|
||||
|
||||
[ListDrawerSettings(Draggable = false, AlwaysExpanded = true)]
|
||||
public Vector3[] vectors;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a00395c39c074032849fd8ac4b9dd3b8
|
||||
timeCreated: 1656856967
|
35
Editor.Samples/Collections/Collections_TableListSample.cs
Normal file
35
Editor.Samples/Collections/Collections_TableListSample.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Collections_TableListSample : ScriptableObject
|
||||
{
|
||||
[TableList(Draggable = true,
|
||||
HideAddButton = false,
|
||||
HideRemoveButton = false,
|
||||
AlwaysExpanded = false)]
|
||||
public List<TableItem> table;
|
||||
|
||||
[Serializable]
|
||||
public class TableItem
|
||||
{
|
||||
[Required]
|
||||
public Texture icon;
|
||||
|
||||
public string description;
|
||||
|
||||
[Group("Combined"), LabelWidth(16)]
|
||||
public string A, B, C;
|
||||
|
||||
[Button, Group("Actions")]
|
||||
public void Test1()
|
||||
{
|
||||
}
|
||||
|
||||
[Button, Group("Actions")]
|
||||
public void Test2()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75e67511762f4ce8bb50e9a5edbd0a1a
|
||||
timeCreated: 1656855664
|
3
Editor.Samples/Conditionals.meta
Normal file
3
Editor.Samples/Conditionals.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25430c3d53e5452496a9480ebfc66910
|
||||
timeCreated: 1656857004
|
10
Editor.Samples/Conditionals/Conditionals_DisableIfSample.cs
Normal file
10
Editor.Samples/Conditionals/Conditionals_DisableIfSample.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Conditionals_DisableIfSample : ScriptableObject
|
||||
{
|
||||
public bool visible;
|
||||
|
||||
[DisableIf(nameof(visible))]
|
||||
public float val;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be63fdfd5bfc446eb40431b63ad4a582
|
||||
timeCreated: 1656857086
|
10
Editor.Samples/Conditionals/Conditionals_EnableIfSample.cs
Normal file
10
Editor.Samples/Conditionals/Conditionals_EnableIfSample.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Conditionals_EnableIfSample : ScriptableObject
|
||||
{
|
||||
public bool visible;
|
||||
|
||||
[EnableIf(nameof(visible))]
|
||||
public float val;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b29947c09fc4b7fa1c4c6061eb945f2
|
||||
timeCreated: 1656857082
|
10
Editor.Samples/Conditionals/Conditionals_HideIfSample.cs
Normal file
10
Editor.Samples/Conditionals/Conditionals_HideIfSample.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Conditionals_HideIfSample : ScriptableObject
|
||||
{
|
||||
public bool visible;
|
||||
|
||||
[HideIf(nameof(visible))]
|
||||
public float val;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2544a3528997409eb700ca65f1be0147
|
||||
timeCreated: 1656857076
|
23
Editor.Samples/Conditionals/Conditionals_ShowIfSample.cs
Normal file
23
Editor.Samples/Conditionals/Conditionals_ShowIfSample.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Conditionals_ShowIfSample : ScriptableObject
|
||||
{
|
||||
public Material material;
|
||||
public bool toggle;
|
||||
public SomeEnum someEnum;
|
||||
|
||||
[ShowIf(nameof(material), null)]
|
||||
public Vector3 showWhenMaterialIsNull;
|
||||
|
||||
[ShowIf(nameof(toggle))]
|
||||
public Vector3 showWhenToggleIsTrue;
|
||||
|
||||
[ShowIf(nameof(toggle), false)]
|
||||
public Vector3 showWhenToggleIsFalse;
|
||||
|
||||
[ShowIf(nameof(someEnum), SomeEnum.Two)]
|
||||
public Vector3 showWhenSomeEnumIsTwo;
|
||||
|
||||
public enum SomeEnum { One, Two, Three }
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 327bc8430b4746e0860a9017e86853d6
|
||||
timeCreated: 1656857013
|
3
Editor.Samples/Debug.meta
Normal file
3
Editor.Samples/Debug.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3220f412f1a347aca8175b14166b0664
|
||||
timeCreated: 1656857161
|
12
Editor.Samples/Debug/Debug_ShowDrawerChainSample.cs
Normal file
12
Editor.Samples/Debug/Debug_ShowDrawerChainSample.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Debug_ShowDrawerChainSample : ScriptableObject
|
||||
{
|
||||
[ShowDrawerChain]
|
||||
[Indent]
|
||||
[PropertySpace]
|
||||
[Title("Custom Title")]
|
||||
[GUIColor(1.0f, 0.8f, 0.8f)]
|
||||
public Vector3 vec;
|
||||
}
|
3
Editor.Samples/Debug/Debug_ShowDrawerChainSample.cs.meta
Normal file
3
Editor.Samples/Debug/Debug_ShowDrawerChainSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 740fa4ad939943b2878ae3059062ba9e
|
||||
timeCreated: 1656857166
|
3
Editor.Samples/Groups.meta
Normal file
3
Editor.Samples/Groups.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1198759fd8a454ea350699846604c21
|
||||
timeCreated: 1656857197
|
35
Editor.Samples/Groups/Groups_GroupsSample.cs
Normal file
35
Editor.Samples/Groups/Groups_GroupsSample.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
[DeclareHorizontalGroup("header")]
|
||||
[DeclareBoxGroup("header/left", Title = "My Left Box")]
|
||||
[DeclareVerticalGroup("header/right")]
|
||||
[DeclareBoxGroup("header/right/top", Title = "My Right Box")]
|
||||
[DeclareTabGroup("header/right/tabs")]
|
||||
[DeclareBoxGroup("body")]
|
||||
public class Groups_GroupsSample : ScriptableObject
|
||||
{
|
||||
[Group("header/left")] public bool prop1;
|
||||
[Group("header/left")] public int prop2;
|
||||
[Group("header/left")] public string prop3;
|
||||
[Group("header/left")] public Vector3 prop4;
|
||||
|
||||
[Group("header/right/top")] public string rightProp;
|
||||
|
||||
[Group("body")] public string body1;
|
||||
[Group("body")] public string body2;
|
||||
|
||||
[Group("header/right/tabs"), Tab("One")]
|
||||
public float tabOne;
|
||||
|
||||
[Group("header/right/tabs"), Tab("Two")]
|
||||
public float tabTwo;
|
||||
|
||||
[Group("header/right/tabs"), Tab("Three")]
|
||||
public float tabThree;
|
||||
|
||||
[Group("header/right"), Button("Click me!")]
|
||||
public void MyButton()
|
||||
{
|
||||
}
|
||||
}
|
3
Editor.Samples/Groups/Groups_GroupsSample.cs.meta
Normal file
3
Editor.Samples/Groups/Groups_GroupsSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89326426f95d4de489da63baf6efc988
|
||||
timeCreated: 1656857201
|
3
Editor.Samples/Misc.meta
Normal file
3
Editor.Samples/Misc.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93e5166924a248f582d65708efbddf0a
|
||||
timeCreated: 1656852588
|
13
Editor.Samples/Misc/Misc_OnValueChangedSample.cs
Normal file
13
Editor.Samples/Misc/Misc_OnValueChangedSample.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Misc_OnValueChangedSample : ScriptableObject
|
||||
{
|
||||
[OnValueChanged(nameof(OnMaterialChanged))]
|
||||
public Material mat;
|
||||
|
||||
private void OnMaterialChanged()
|
||||
{
|
||||
Debug.Log("Material changed!");
|
||||
}
|
||||
}
|
3
Editor.Samples/Misc/Misc_OnValueChangedSample.cs.meta
Normal file
3
Editor.Samples/Misc/Misc_OnValueChangedSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7068787aa2c749b992eab640bba2d436
|
||||
timeCreated: 1656856619
|
10
Editor.Samples/Misc/Misc_PropertyOrderSample.cs
Normal file
10
Editor.Samples/Misc/Misc_PropertyOrderSample.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Misc_PropertyOrderSample : ScriptableObject
|
||||
{
|
||||
public float first;
|
||||
|
||||
[PropertyOrder(0)]
|
||||
public float second;
|
||||
}
|
3
Editor.Samples/Misc/Misc_PropertyOrderSample.cs.meta
Normal file
3
Editor.Samples/Misc/Misc_PropertyOrderSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c14c7b55b1374730833ca86db22fb4fe
|
||||
timeCreated: 1656856254
|
8
Editor.Samples/Misc/Misc_ReadOnlySample.cs
Normal file
8
Editor.Samples/Misc/Misc_ReadOnlySample.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Misc_ReadOnlySample : ScriptableObject
|
||||
{
|
||||
[ReadOnly]
|
||||
public Vector3 vec;
|
||||
}
|
3
Editor.Samples/Misc/Misc_ReadOnlySample.cs.meta
Normal file
3
Editor.Samples/Misc/Misc_ReadOnlySample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8188742392614449bf6c0ff330488ea0
|
||||
timeCreated: 1656856352
|
17
Editor.Samples/Misc/Misc_ShowInInspectorSample.cs
Normal file
17
Editor.Samples/Misc/Misc_ShowInInspectorSample.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Misc_ShowInInspectorSample : ScriptableObject
|
||||
{
|
||||
private float _field;
|
||||
|
||||
[ShowInInspector]
|
||||
public float ReadOnlyProperty => _field;
|
||||
|
||||
[ShowInInspector]
|
||||
public float EditableProperty
|
||||
{
|
||||
get => _field;
|
||||
set => _field = value;
|
||||
}
|
||||
}
|
3
Editor.Samples/Misc/Misc_ShowInInspectorSample.cs.meta
Normal file
3
Editor.Samples/Misc/Misc_ShowInInspectorSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e605b771ea2468da31945707d0fb76a
|
||||
timeCreated: 1656848081
|
32
Editor.Samples/SampleWindowStyles.cs
Normal file
32
Editor.Samples/SampleWindowStyles.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriInspector.Editor.Samples
|
||||
{
|
||||
internal static class SampleWindowStyles
|
||||
{
|
||||
public static readonly GUIStyle Padding;
|
||||
public static readonly GUIStyle BoxWithPadding;
|
||||
public static readonly GUIStyle HeaderDisplayNameLabel;
|
||||
|
||||
static SampleWindowStyles()
|
||||
{
|
||||
Padding = new GUIStyle(GUI.skin.label)
|
||||
{
|
||||
padding = new RectOffset(5, 5, 5, 5),
|
||||
};
|
||||
|
||||
BoxWithPadding = new GUIStyle(TriEditorStyles.Box)
|
||||
{
|
||||
padding = new RectOffset(5, 5, 5, 5),
|
||||
};
|
||||
|
||||
HeaderDisplayNameLabel = new GUIStyle(EditorStyles.largeLabel)
|
||||
{
|
||||
fontStyle = FontStyle.Bold,
|
||||
fontSize = 17,
|
||||
margin = new RectOffset(5, 5, 5, 0),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
3
Editor.Samples/SampleWindowStyles.cs.meta
Normal file
3
Editor.Samples/SampleWindowStyles.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddb081b7f73a4b58aca6d24aaefbc50e
|
||||
timeCreated: 1656858907
|
3
Editor.Samples/Styling.meta
Normal file
3
Editor.Samples/Styling.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da4c8e005b7646358db1c3c4811a1865
|
||||
timeCreated: 1656856718
|
20
Editor.Samples/Styling/Styling_GUIColorSample.cs
Normal file
20
Editor.Samples/Styling/Styling_GUIColorSample.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_GUIColorSample : ScriptableObject
|
||||
{
|
||||
[GUIColor(0.8f, 1.0f, 0.6f)]
|
||||
public Vector3 vec;
|
||||
|
||||
[GUIColor(0.6f, 0.9f, 1.0f)]
|
||||
[Button]
|
||||
public void BlueButton()
|
||||
{
|
||||
}
|
||||
|
||||
[GUIColor(1.0f, 0.6f, 0.6f)]
|
||||
[Button]
|
||||
public void RedButton()
|
||||
{
|
||||
}
|
||||
}
|
3
Editor.Samples/Styling/Styling_GUIColorSample.cs.meta
Normal file
3
Editor.Samples/Styling/Styling_GUIColorSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f99fc38989d4471da97400b0a2a812ff
|
||||
timeCreated: 1656856827
|
13
Editor.Samples/Styling/Styling_HideLabelSample.cs
Normal file
13
Editor.Samples/Styling/Styling_HideLabelSample.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_HideLabelSample : ScriptableObject
|
||||
{
|
||||
[Title("Wide Vector")]
|
||||
[HideLabel]
|
||||
public Vector3 vector;
|
||||
|
||||
[Title("Wide String")]
|
||||
[HideLabel]
|
||||
public string str;
|
||||
}
|
3
Editor.Samples/Styling/Styling_HideLabelSample.cs.meta
Normal file
3
Editor.Samples/Styling/Styling_HideLabelSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f39878f7ed574f7898bf55caf8d8e607
|
||||
timeCreated: 1656856749
|
18
Editor.Samples/Styling/Styling_IndentSample.cs
Normal file
18
Editor.Samples/Styling/Styling_IndentSample.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_IndentSample : ScriptableObject
|
||||
{
|
||||
[Title("Custom Indent")]
|
||||
[Indent]
|
||||
public int a;
|
||||
|
||||
[Indent(2)]
|
||||
public int b;
|
||||
|
||||
[Indent(3)]
|
||||
public int c;
|
||||
|
||||
[Indent(4)]
|
||||
public int d;
|
||||
}
|
3
Editor.Samples/Styling/Styling_IndentSample.cs.meta
Normal file
3
Editor.Samples/Styling/Styling_IndentSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f33bec5e9334e10949fbf94ae0a21f5
|
||||
timeCreated: 1656856846
|
8
Editor.Samples/Styling/Styling_InlineEditorSample.cs
Normal file
8
Editor.Samples/Styling/Styling_InlineEditorSample.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_InlineEditorSample : ScriptableObject
|
||||
{
|
||||
[InlineEditor]
|
||||
public Material mat;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 151f5ace94624b5b9fa4b4ee34b5e41f
|
||||
timeCreated: 1656856914
|
18
Editor.Samples/Styling/Styling_InlinePropertySample.cs
Normal file
18
Editor.Samples/Styling/Styling_InlinePropertySample.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_InlinePropertySample : ScriptableObject
|
||||
{
|
||||
public MinMax rangeFoldout;
|
||||
|
||||
[InlineProperty(LabelWidth = 40)]
|
||||
public MinMax rangeInline;
|
||||
|
||||
[Serializable]
|
||||
public class MinMax
|
||||
{
|
||||
public int min;
|
||||
public int max;
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0ee1888cb6649ceafe31245787ac0e5
|
||||
timeCreated: 1656856939
|
14
Editor.Samples/Styling/Styling_LabelTextSample.cs
Normal file
14
Editor.Samples/Styling/Styling_LabelTextSample.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_LabelTextSample : ScriptableObject
|
||||
{
|
||||
[LabelText("Custom Label")]
|
||||
public int val;
|
||||
|
||||
[LabelText("$" + nameof(DynamicLabel))]
|
||||
public Vector3 vec;
|
||||
|
||||
public string DynamicLabel => DateTime.Now.ToShortTimeString();
|
||||
}
|
3
Editor.Samples/Styling/Styling_LabelTextSample.cs.meta
Normal file
3
Editor.Samples/Styling/Styling_LabelTextSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d6fabaf62504cf682d96b5245e4a3f5
|
||||
timeCreated: 1656856777
|
13
Editor.Samples/Styling/Styling_LabelWidthSample.cs
Normal file
13
Editor.Samples/Styling/Styling_LabelWidthSample.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_LabelWidthSample : ScriptableObject
|
||||
{
|
||||
public int defaultWidth;
|
||||
|
||||
[LabelWidth(40)]
|
||||
public int thin;
|
||||
|
||||
[LabelWidth(300)]
|
||||
public int customInspectorVeryLongPropertyName;
|
||||
}
|
3
Editor.Samples/Styling/Styling_LabelWidthSample.cs.meta
Normal file
3
Editor.Samples/Styling/Styling_LabelWidthSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 114e6af58ba440469f9a80c8094944f3
|
||||
timeCreated: 1656856804
|
15
Editor.Samples/Styling/Styling_PropertySpaceSample.cs
Normal file
15
Editor.Samples/Styling/Styling_PropertySpaceSample.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_PropertySpaceSample : ScriptableObject
|
||||
{
|
||||
[Space, PropertyOrder(0)]
|
||||
public Vector3 vecField;
|
||||
|
||||
[ShowInInspector, PropertyOrder(1)]
|
||||
[PropertySpace(SpaceBefore = 10, SpaceAfter = 30)]
|
||||
public Rect RectProperty { get; set; }
|
||||
|
||||
[PropertyOrder(2)]
|
||||
public bool b;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ba5d5c0bd824ccc8cdfb279d18821c3
|
||||
timeCreated: 1656856868
|
14
Editor.Samples/Styling/Styling_PropertyTooltipSample.cs
Normal file
14
Editor.Samples/Styling/Styling_PropertyTooltipSample.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_PropertyTooltipSample : ScriptableObject
|
||||
{
|
||||
[PropertyTooltip("This is tooltip")]
|
||||
public Rect rect;
|
||||
|
||||
[PropertyTooltip("$" + nameof(DynamicTooltip))]
|
||||
public Vector3 vec;
|
||||
|
||||
public string DynamicTooltip => DateTime.Now.ToShortTimeString();
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 866d0af24dd1465798f6fc588a18f0ac
|
||||
timeCreated: 1656856888
|
25
Editor.Samples/Styling/Styling_TitleSample.cs
Normal file
25
Editor.Samples/Styling/Styling_TitleSample.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Styling_TitleSample : ScriptableObject
|
||||
{
|
||||
[Title("My Title")]
|
||||
public string val;
|
||||
|
||||
[Title("$" + nameof(_myTitleField))]
|
||||
public Rect rect;
|
||||
|
||||
[Title("$" + nameof(MyTitleProperty))]
|
||||
public Vector3 vec;
|
||||
|
||||
[Title("Button Title")]
|
||||
[Button]
|
||||
public void MyButton()
|
||||
{
|
||||
}
|
||||
|
||||
private string _myTitleField = "Serialized Title";
|
||||
|
||||
private string MyTitleProperty => DateTime.Now.ToLongTimeString();
|
||||
}
|
3
Editor.Samples/Styling/Styling_TitleSample.cs.meta
Normal file
3
Editor.Samples/Styling/Styling_TitleSample.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e54656b5b8ed48f2affb7d716661cddd
|
||||
timeCreated: 1656856725
|
18
Editor.Samples/TriInspector.Editor.Samples.asmdef
Normal file
18
Editor.Samples/TriInspector.Editor.Samples.asmdef
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "TriInspector.Editor.Samples",
|
||||
"references": [
|
||||
"TriInspector",
|
||||
"TriInspector.Editor"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
7
Editor.Samples/TriInspector.Editor.Samples.asmdef.meta
Normal file
7
Editor.Samples/TriInspector.Editor.Samples.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fd3d95cbfe66d744a1e3a709d4c510d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
257
Editor.Samples/TriSamplesWindow.cs
Normal file
257
Editor.Samples/TriSamplesWindow.cs
Normal file
@ -0,0 +1,257 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TriInspector.Utilities;
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TriInspector.Editor.Samples
|
||||
{
|
||||
internal class TriSamplesWindow : EditorWindow
|
||||
{
|
||||
private MenuTree _menuTree;
|
||||
private SearchField _searchField;
|
||||
|
||||
private ScriptableObject _current;
|
||||
private SerializedObject _currentSerializedObject;
|
||||
private TriPropertyTree _currentPropertyTree;
|
||||
private MonoScript _currentMonoScript;
|
||||
private Vector2 _currentScroll;
|
||||
|
||||
[MenuItem("Tools/Tri Inspector/Samples")]
|
||||
public static void Open()
|
||||
{
|
||||
var window = GetWindow<TriSamplesWindow>();
|
||||
window.titleContent = new GUIContent("Tri Samples");
|
||||
window.Show();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_menuTree = new MenuTree(new TreeViewState());
|
||||
_menuTree.SelectedTypeChanged += ChangeCurrentSample;
|
||||
|
||||
_searchField = new SearchField();
|
||||
_searchField.downOrUpArrowKeyPressed += _menuTree.SetFocusAndEnsureSelectedItem;
|
||||
|
||||
_menuTree.Reload();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
ChangeCurrentSample(null);
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
using (new GUILayout.HorizontalScope())
|
||||
{
|
||||
using (new GUILayout.VerticalScope(GUILayout.Width(200)))
|
||||
{
|
||||
DrawMenu();
|
||||
}
|
||||
|
||||
var separatorRect = GUILayoutUtility.GetLastRect();
|
||||
separatorRect.xMin = separatorRect.xMax;
|
||||
separatorRect.xMax += 1;
|
||||
GUI.Box(separatorRect, "");
|
||||
|
||||
using (new GUILayout.VerticalScope())
|
||||
{
|
||||
DrawElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawMenu()
|
||||
{
|
||||
using (new GUILayout.HorizontalScope(EditorStyles.toolbar, GUILayout.ExpandWidth(true)))
|
||||
{
|
||||
GUILayout.Space(5);
|
||||
_menuTree.searchString = _searchField.OnToolbarGUI(_menuTree.searchString, GUILayout.ExpandWidth(true));
|
||||
GUILayout.Space(5);
|
||||
}
|
||||
|
||||
var menuRect = GUILayoutUtility.GetRect(0, 100000, 0, 100000);
|
||||
_menuTree.OnGUI(menuRect);
|
||||
}
|
||||
|
||||
private void DrawElement()
|
||||
{
|
||||
if (_currentPropertyTree == null || _currentMonoScript == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (var scrollScope = new GUILayout.ScrollViewScope(_currentScroll))
|
||||
{
|
||||
_currentScroll = scrollScope.scrollPosition;
|
||||
|
||||
using (new GUILayout.VerticalScope(SampleWindowStyles.Padding))
|
||||
{
|
||||
GUILayout.Label(_current.name, SampleWindowStyles.HeaderDisplayNameLabel);
|
||||
|
||||
_currentSerializedObject.UpdateIfRequiredOrScript();
|
||||
_currentPropertyTree.Update();
|
||||
|
||||
if (_currentPropertyTree.ValidationRequired)
|
||||
{
|
||||
_currentPropertyTree.RunValidation();
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
GUILayout.Label("Preview", EditorStyles.boldLabel);
|
||||
|
||||
using (TriGuiHelper.PushEditorTarget(_current))
|
||||
using (new GUILayout.VerticalScope(SampleWindowStyles.BoxWithPadding))
|
||||
{
|
||||
var viewWidth = GUILayoutUtility.GetRect(0, 10000, 0, 0).width;
|
||||
_currentPropertyTree.Draw(viewWidth);
|
||||
}
|
||||
|
||||
if (_currentSerializedObject.ApplyModifiedProperties())
|
||||
{
|
||||
_currentPropertyTree.RequestValidation();
|
||||
}
|
||||
|
||||
if (_currentPropertyTree.RepaintRequired)
|
||||
{
|
||||
Repaint();
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
GUILayout.Label("Code", EditorStyles.boldLabel);
|
||||
|
||||
using (new GUILayout.VerticalScope(SampleWindowStyles.BoxWithPadding))
|
||||
{
|
||||
GUILayout.TextField(_currentMonoScript.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeCurrentSample(Type type)
|
||||
{
|
||||
if (_current != null)
|
||||
{
|
||||
DestroyImmediate(_current);
|
||||
_current = null;
|
||||
}
|
||||
|
||||
if (_currentSerializedObject != null)
|
||||
{
|
||||
_currentSerializedObject.Dispose();
|
||||
_currentSerializedObject = null;
|
||||
}
|
||||
|
||||
if (_currentPropertyTree != null)
|
||||
{
|
||||
_currentPropertyTree.Dispose();
|
||||
_currentPropertyTree = null;
|
||||
}
|
||||
|
||||
_currentScroll = Vector2.zero;
|
||||
|
||||
if (type != null)
|
||||
{
|
||||
_current = CreateInstance(type);
|
||||
_current.name = GetTypeNiceName(type);
|
||||
_current.hideFlags = HideFlags.DontSave;
|
||||
|
||||
_currentSerializedObject = new SerializedObject(_current);
|
||||
_currentMonoScript = MonoScript.FromScriptableObject(_current);
|
||||
_currentPropertyTree = new TriPropertyTreeForSerializedObject(_currentSerializedObject);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetTypeNiceName(Type type)
|
||||
{
|
||||
var name = type.Name;
|
||||
|
||||
if (name.Contains('_'))
|
||||
{
|
||||
var index = name.IndexOf('_');
|
||||
name = name.Substring(index + 1);
|
||||
}
|
||||
|
||||
if (name.EndsWith("Sample"))
|
||||
{
|
||||
name = name.Remove(name.Length - "Sample".Length);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
private class MenuTree : TreeView
|
||||
{
|
||||
private readonly Dictionary<string, GroupItem> _groups = new Dictionary<string, GroupItem>();
|
||||
|
||||
public event Action<Type> SelectedTypeChanged;
|
||||
|
||||
public MenuTree(TreeViewState state) : base(state)
|
||||
{
|
||||
}
|
||||
|
||||
protected override bool CanMultiSelect(TreeViewItem item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void SelectionChanged(IList<int> selectedIds)
|
||||
{
|
||||
base.SelectionChanged(selectedIds);
|
||||
|
||||
var type = selectedIds.Count > 0 && FindItem(selectedIds[0], rootItem) is SampleItem sampleItem
|
||||
? sampleItem.Type
|
||||
: null;
|
||||
|
||||
SelectedTypeChanged?.Invoke(type);
|
||||
}
|
||||
|
||||
protected override TreeViewItem BuildRoot()
|
||||
{
|
||||
var root = new TreeViewItem(-1, -1);
|
||||
|
||||
var sampleTypes = typeof(TriSamplesWindow).Assembly.GetTypes()
|
||||
.Where(type => type.BaseType == typeof(ScriptableObject))
|
||||
.OrderBy(type => type.Name)
|
||||
.ToList();
|
||||
|
||||
var id = 0;
|
||||
foreach (var sampleType in sampleTypes)
|
||||
{
|
||||
var group = sampleType.Name.Split('_')[0];
|
||||
|
||||
if (!_groups.TryGetValue(group, out var groupItem))
|
||||
{
|
||||
_groups[group] = groupItem = new GroupItem(++id, group);
|
||||
|
||||
root.AddChild(groupItem);
|
||||
}
|
||||
|
||||
groupItem.AddChild(new SampleItem(++id, sampleType));
|
||||
}
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private class GroupItem : TreeViewItem
|
||||
{
|
||||
public GroupItem(int id, string name) : base(id, 0, name)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class SampleItem : TreeViewItem
|
||||
{
|
||||
public Type Type { get; }
|
||||
|
||||
public SampleItem(int id, Type type) : base(id, 1, GetTypeNiceName(type))
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
Editor.Samples/TriSamplesWindow.cs.meta
Normal file
3
Editor.Samples/TriSamplesWindow.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a36cdbb8bee439f988a44ff424593bb
|
||||
timeCreated: 1656847262
|
3
Editor.Samples/Validators.meta
Normal file
3
Editor.Samples/Validators.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7160cc0e3bd4f1a8cb43ea3c2b00c7f
|
||||
timeCreated: 1656856456
|
8
Editor.Samples/Validators/Validators_AssetsOnlySample.cs
Normal file
8
Editor.Samples/Validators/Validators_AssetsOnlySample.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Validators_AssetsOnlySample : ScriptableObject
|
||||
{
|
||||
[AssetsOnly]
|
||||
public GameObject obj;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 374fcd38854b483a83cdde8ef3c1faba
|
||||
timeCreated: 1656856695
|
26
Editor.Samples/Validators/Validators_InfoBoxSample.cs
Normal file
26
Editor.Samples/Validators/Validators_InfoBoxSample.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Validators_InfoBoxSample : ScriptableObject
|
||||
{
|
||||
[Title("InfoBox Message Types")]
|
||||
[InfoBox("Default info box")]
|
||||
public int a;
|
||||
|
||||
[InfoBox("None info box", TriMessageType.None)]
|
||||
public int b;
|
||||
|
||||
[InfoBox("Warning info box", TriMessageType.Warning)]
|
||||
public int c;
|
||||
|
||||
[InfoBox("Error info box", TriMessageType.Error)]
|
||||
public int d;
|
||||
|
||||
[InfoBox("$" + nameof(DynamicInfo), visibleIf: nameof(VisibleInEditMode))]
|
||||
public Vector3 vec;
|
||||
|
||||
private string DynamicInfo => "Dynamic info box: " + DateTime.Now.ToLongTimeString();
|
||||
|
||||
private bool VisibleInEditMode => !Application.isPlaying;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86a17b90790548718bdb5d26c8a83c95
|
||||
timeCreated: 1656856674
|
8
Editor.Samples/Validators/Validators_RequiredSample.cs
Normal file
8
Editor.Samples/Validators/Validators_RequiredSample.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Validators_RequiredSample : ScriptableObject
|
||||
{
|
||||
[Required]
|
||||
public Material mat;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26503f30077744908a680c7464ee7991
|
||||
timeCreated: 1656856504
|
15
Editor.Samples/Validators/Validators_ValidateInputSample.cs
Normal file
15
Editor.Samples/Validators/Validators_ValidateInputSample.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using TriInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class Validators_ValidateInputSample : ScriptableObject
|
||||
{
|
||||
[ValidateInput(nameof(ValidateTexture))]
|
||||
public Texture tex;
|
||||
|
||||
private TriValidationResult ValidateTexture()
|
||||
{
|
||||
if (tex == null) return TriValidationResult.Error("Tex is null");
|
||||
if (!tex.isReadable) return TriValidationResult.Warning("Tex must be readable");
|
||||
return TriValidationResult.Valid;
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75ac78d47ba34b6380df278a3e641e87
|
||||
timeCreated: 1656856540
|
@ -1,3 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("TriInspector.Editor.Samples")]
|
||||
[assembly: InternalsVisibleTo("TriInspector.Editor.Integrations.Odin")]
|
@ -48,7 +48,7 @@ namespace TriInspector
|
||||
RequestRepaint();
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
public void Draw(float? viewWidth = null)
|
||||
{
|
||||
RepaintRequired = false;
|
||||
|
||||
@ -62,7 +62,7 @@ namespace TriInspector
|
||||
}
|
||||
|
||||
_rootPropertyElement.Update();
|
||||
var width = EditorGUIUtility.currentViewWidth;
|
||||
var width = viewWidth ?? EditorGUIUtility.currentViewWidth;
|
||||
var height = _rootPropertyElement.GetHeight(width);
|
||||
var rect = GUILayoutUtility.GetRect(width, height);
|
||||
rect.xMin += 3;
|
||||
|
@ -6,6 +6,7 @@ _Advanced inspector attributes for Unity_
|
||||
|
||||
- [How to Install](#How-to-Install)
|
||||
- [Roadmap](#Roadmap)
|
||||
- [Samples](#Samples)
|
||||
- [Attributes](#Attributes)
|
||||
- [Misc](#Misc)
|
||||
- [Validation](#Validation)
|
||||
@ -35,6 +36,11 @@ After package installation **run the Installer** by double clicking on it.
|
||||
## Roadmap ![GitHub Repo stars](https://img.shields.io/github/stars/codewriter-packages/Tri-Inspector?style=social)
|
||||
Each star ★ on the project page brings new features closer. See roadmap and more info [here](https://github.com/codewriter-packages/Tri-Inspector/issues/9).
|
||||
|
||||
## Samples
|
||||
|
||||
TriInspector has built-in samples at `Tools/Tri Inspector/Samples` menu.
|
||||
![Samples](https://user-images.githubusercontent.com/26966368/177045336-a3fcf438-3e70-45d0-b753-299e577b2010.png)
|
||||
|
||||
## Attributes
|
||||
|
||||
### Misc
|
||||
|
Loading…
Reference in New Issue
Block a user