Add samples window - Tools/Tri Inspector/Samples

This commit is contained in:
VladV 2022-07-03 17:59:35 +03:00
parent 46109e5520
commit 2ee3ed2fb7
74 changed files with 894 additions and 2 deletions

8
Editor.Samples.meta Normal file
View File

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

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1068a85eb61646efb6cffc2680cf0be3
timeCreated: 1656857100

View File

@ -0,0 +1,11 @@
using TriInspector;
using UnityEngine;
public class Buttons_ButtonSample : ScriptableObject
{
[Button("Click me!")]
private void DoButton()
{
Debug.Log("Button clicked!");
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cfc765523b0944faa880f75c257dc865
timeCreated: 1656857108

View 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,
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a5287edf013a41608e8082a8766f1f1a
timeCreated: 1656857128

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f188dac8f6fb4d7cb4251a6d0a3469a9
timeCreated: 1656855659

View File

@ -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;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a00395c39c074032849fd8ac4b9dd3b8
timeCreated: 1656856967

View 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()
{
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 75e67511762f4ce8bb50e9a5edbd0a1a
timeCreated: 1656855664

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 25430c3d53e5452496a9480ebfc66910
timeCreated: 1656857004

View File

@ -0,0 +1,10 @@
using TriInspector;
using UnityEngine;
public class Conditionals_DisableIfSample : ScriptableObject
{
public bool visible;
[DisableIf(nameof(visible))]
public float val;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: be63fdfd5bfc446eb40431b63ad4a582
timeCreated: 1656857086

View File

@ -0,0 +1,10 @@
using TriInspector;
using UnityEngine;
public class Conditionals_EnableIfSample : ScriptableObject
{
public bool visible;
[EnableIf(nameof(visible))]
public float val;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0b29947c09fc4b7fa1c4c6061eb945f2
timeCreated: 1656857082

View File

@ -0,0 +1,10 @@
using TriInspector;
using UnityEngine;
public class Conditionals_HideIfSample : ScriptableObject
{
public bool visible;
[HideIf(nameof(visible))]
public float val;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2544a3528997409eb700ca65f1be0147
timeCreated: 1656857076

View 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 }
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 327bc8430b4746e0860a9017e86853d6
timeCreated: 1656857013

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3220f412f1a347aca8175b14166b0664
timeCreated: 1656857161

View 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;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 740fa4ad939943b2878ae3059062ba9e
timeCreated: 1656857166

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d1198759fd8a454ea350699846604c21
timeCreated: 1656857197

View 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()
{
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 89326426f95d4de489da63baf6efc988
timeCreated: 1656857201

3
Editor.Samples/Misc.meta Normal file
View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 93e5166924a248f582d65708efbddf0a
timeCreated: 1656852588

View 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!");
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7068787aa2c749b992eab640bba2d436
timeCreated: 1656856619

View File

@ -0,0 +1,10 @@
using TriInspector;
using UnityEngine;
public class Misc_PropertyOrderSample : ScriptableObject
{
public float first;
[PropertyOrder(0)]
public float second;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c14c7b55b1374730833ca86db22fb4fe
timeCreated: 1656856254

View File

@ -0,0 +1,8 @@
using TriInspector;
using UnityEngine;
public class Misc_ReadOnlySample : ScriptableObject
{
[ReadOnly]
public Vector3 vec;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8188742392614449bf6c0ff330488ea0
timeCreated: 1656856352

View 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;
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3e605b771ea2468da31945707d0fb76a
timeCreated: 1656848081

View 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),
};
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ddb081b7f73a4b58aca6d24aaefbc50e
timeCreated: 1656858907

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: da4c8e005b7646358db1c3c4811a1865
timeCreated: 1656856718

View 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()
{
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f99fc38989d4471da97400b0a2a812ff
timeCreated: 1656856827

View 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;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f39878f7ed574f7898bf55caf8d8e607
timeCreated: 1656856749

View 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;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1f33bec5e9334e10949fbf94ae0a21f5
timeCreated: 1656856846

View File

@ -0,0 +1,8 @@
using TriInspector;
using UnityEngine;
public class Styling_InlineEditorSample : ScriptableObject
{
[InlineEditor]
public Material mat;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 151f5ace94624b5b9fa4b4ee34b5e41f
timeCreated: 1656856914

View 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;
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e0ee1888cb6649ceafe31245787ac0e5
timeCreated: 1656856939

View 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();
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7d6fabaf62504cf682d96b5245e4a3f5
timeCreated: 1656856777

View 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;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 114e6af58ba440469f9a80c8094944f3
timeCreated: 1656856804

View 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;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6ba5d5c0bd824ccc8cdfb279d18821c3
timeCreated: 1656856868

View 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();
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 866d0af24dd1465798f6fc588a18f0ac
timeCreated: 1656856888

View 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();
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e54656b5b8ed48f2affb7d716661cddd
timeCreated: 1656856725

View 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
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6fd3d95cbfe66d744a1e3a709d4c510d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8a36cdbb8bee439f988a44ff424593bb
timeCreated: 1656847262

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b7160cc0e3bd4f1a8cb43ea3c2b00c7f
timeCreated: 1656856456

View File

@ -0,0 +1,8 @@
using TriInspector;
using UnityEngine;
public class Validators_AssetsOnlySample : ScriptableObject
{
[AssetsOnly]
public GameObject obj;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 374fcd38854b483a83cdde8ef3c1faba
timeCreated: 1656856695

View 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;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 86a17b90790548718bdb5d26c8a83c95
timeCreated: 1656856674

View File

@ -0,0 +1,8 @@
using TriInspector;
using UnityEngine;
public class Validators_RequiredSample : ScriptableObject
{
[Required]
public Material mat;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 26503f30077744908a680c7464ee7991
timeCreated: 1656856504

View 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;
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 75ac78d47ba34b6380df278a3e641e87
timeCreated: 1656856540

View File

@ -1,3 +1,4 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("TriInspector.Editor.Samples")]
[assembly: InternalsVisibleTo("TriInspector.Editor.Integrations.Odin")] [assembly: InternalsVisibleTo("TriInspector.Editor.Integrations.Odin")]

View File

@ -48,7 +48,7 @@ namespace TriInspector
RequestRepaint(); RequestRepaint();
} }
public void Draw() public void Draw(float? viewWidth = null)
{ {
RepaintRequired = false; RepaintRequired = false;
@ -62,7 +62,7 @@ namespace TriInspector
} }
_rootPropertyElement.Update(); _rootPropertyElement.Update();
var width = EditorGUIUtility.currentViewWidth; var width = viewWidth ?? EditorGUIUtility.currentViewWidth;
var height = _rootPropertyElement.GetHeight(width); var height = _rootPropertyElement.GetHeight(width);
var rect = GUILayoutUtility.GetRect(width, height); var rect = GUILayoutUtility.GetRect(width, height);
rect.xMin += 3; rect.xMin += 3;

View File

@ -6,6 +6,7 @@ _Advanced inspector attributes for Unity_
- [How to Install](#How-to-Install) - [How to Install](#How-to-Install)
- [Roadmap](#Roadmap) - [Roadmap](#Roadmap)
- [Samples](#Samples)
- [Attributes](#Attributes) - [Attributes](#Attributes)
- [Misc](#Misc) - [Misc](#Misc)
- [Validation](#Validation) - [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) ## 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). 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 ## Attributes
### Misc ### Misc