Is Root#
Transform / Hierarchy / Is Root
Description#
Checks whether the root parent of a Transform is equal to another one
Parameters#
| Name | Description |
|---|---|
| Transform | The Transform parent root to check |
| Value | The Transform to compare against the parent root |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Is Root")]
[Category("Transform/Hierarchy/Is Root")]
[Description("Checks whether the root parent of a Transform is equal to another one")]
[Image(typeof(IconHanger), ColorTheme.Type.Lime, typeof(BadgeArrowUp))]
[Keywords("Transform")]
[Parameter("Transform", "The Transform parent root to check")]
[Parameter("Value", "The Transform to compare against the parent root")]
[Serializable]
public class ConditionCoreTransformCheckRoot : Condition
{
[SerializeField] private GetGameObject m_Transform = new GetGameObject();
[SerializeField] private GetGameObject m_Value = new GetGameObject();
protected override string GetTitle(GameObject source)
{
string member = TextUtils.ThemeAsKeyword("Root");
return $"{this.m_Transform} {member} = {this.m_Value}";
}
protected override bool Run(Args args)
{
Transform component = this.m_Transform.Get<Transform>(args);
if (component == null) return false;
return component.root == this.m_Value.Get<Transform>(args);
}
}
}