mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 08:18:49 -05:00
Makes InspectorElement creation lazy to avoid tree generation on validation
This commit is contained in:
parent
acdcb60456
commit
2b389d9323
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using TriInspector.Elements;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
@ -8,7 +9,7 @@ namespace TriInspector
|
||||
{
|
||||
public abstract class TriPropertyTree : ITriPropertyParent
|
||||
{
|
||||
private TriInspectorElement _inspectorElement;
|
||||
[CanBeNull] private TriInspectorElement _inspectorElement;
|
||||
|
||||
public IReadOnlyList<TriProperty> Properties { get; protected set; }
|
||||
|
||||
@ -21,21 +22,16 @@ namespace TriInspector
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_inspectorElement = new TriInspectorElement(TargetObjectType, Properties);
|
||||
_inspectorElement.AttachInternal();
|
||||
|
||||
Update();
|
||||
RunValidation();
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (!_inspectorElement.IsAttached)
|
||||
if (_inspectorElement != null && _inspectorElement.IsAttached)
|
||||
{
|
||||
return;
|
||||
_inspectorElement.DetachInternal();
|
||||
}
|
||||
|
||||
_inspectorElement.DetachInternal();
|
||||
}
|
||||
|
||||
public virtual void Update()
|
||||
@ -62,6 +58,12 @@ namespace TriInspector
|
||||
{
|
||||
RepaintRequired = false;
|
||||
|
||||
if (_inspectorElement == null)
|
||||
{
|
||||
_inspectorElement = new TriInspectorElement(TargetObjectType, Properties);
|
||||
_inspectorElement.AttachInternal();
|
||||
}
|
||||
|
||||
_inspectorElement.Update();
|
||||
var width = EditorGUIUtility.currentViewWidth;
|
||||
var height = _inspectorElement.GetHeight(width);
|
||||
|
Loading…
Reference in New Issue
Block a user