2021-04-15 20:18:03 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace UnityExplorer.UI.Widgets
|
|
|
|
|
{
|
|
|
|
|
public class CachedTransform
|
|
|
|
|
{
|
2021-04-16 02:52:54 +10:00
|
|
|
|
public TransformTree Tree { get; }
|
|
|
|
|
public Transform Value { get; private set; }
|
2022-04-09 18:58:56 +10:00
|
|
|
|
public int InstanceID { get; }
|
2021-04-15 20:18:03 +10:00
|
|
|
|
public CachedTransform Parent { get; internal set; }
|
|
|
|
|
|
|
|
|
|
public int Depth { get; internal set; }
|
2021-05-08 06:18:28 +10:00
|
|
|
|
public int ChildCount { get; internal set; }
|
|
|
|
|
public string Name { get; internal set; }
|
2021-05-16 21:46:19 +10:00
|
|
|
|
public bool Enabled { get; internal set; }
|
2022-03-10 04:32:19 +11:00
|
|
|
|
public int SiblingIndex { get; internal set; }
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2022-03-10 17:56:21 +11:00
|
|
|
|
public bool Expanded => Tree.IsTransformExpanded(InstanceID);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public CachedTransform(TransformTree tree, Transform transform, int depth, CachedTransform parent = null)
|
2021-04-15 20:18:03 +10:00
|
|
|
|
{
|
2022-04-09 18:58:56 +10:00
|
|
|
|
InstanceID = transform.GetInstanceID();
|
|
|
|
|
|
2021-04-16 02:52:54 +10:00
|
|
|
|
Tree = tree;
|
|
|
|
|
Value = transform;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
Parent = parent;
|
2022-03-10 04:32:19 +11:00
|
|
|
|
SiblingIndex = transform.GetSiblingIndex();
|
2021-04-26 19:56:21 +10:00
|
|
|
|
Update(transform, depth);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-08 06:18:28 +10:00
|
|
|
|
public bool Update(Transform transform, int depth)
|
2021-04-15 20:18:03 +10:00
|
|
|
|
{
|
2022-03-10 04:32:19 +11:00
|
|
|
|
bool changed = false;
|
2021-05-08 06:18:28 +10:00
|
|
|
|
|
2021-06-05 19:36:09 +10:00
|
|
|
|
if (Value != transform
|
|
|
|
|
|| depth != Depth
|
|
|
|
|
|| ChildCount != transform.childCount
|
|
|
|
|
|| Name != transform.name
|
2022-03-10 04:32:19 +11:00
|
|
|
|
|| Enabled != transform.gameObject.activeSelf
|
|
|
|
|
|| SiblingIndex != transform.GetSiblingIndex())
|
2021-05-08 06:18:28 +10:00
|
|
|
|
{
|
2022-03-10 04:32:19 +11:00
|
|
|
|
changed = true;
|
|
|
|
|
|
2021-05-08 06:18:28 +10:00
|
|
|
|
Value = transform;
|
|
|
|
|
Depth = depth;
|
|
|
|
|
ChildCount = transform.childCount;
|
|
|
|
|
Name = transform.name;
|
2021-05-16 21:46:19 +10:00
|
|
|
|
Enabled = transform.gameObject.activeSelf;
|
2022-03-10 04:32:19 +11:00
|
|
|
|
SiblingIndex = transform.GetSiblingIndex();
|
2021-05-08 06:18:28 +10:00
|
|
|
|
}
|
2022-03-10 04:32:19 +11:00
|
|
|
|
|
|
|
|
|
return changed;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|