Is Parent#
Transform / Hierarchy / Is Parent
Description#
Checks whether the parent of a Transform is equal to another one
Parameters#
| Name | Description |
|---|---|
| Transform | The Transform parent to check |
| Value | The Transform to compare against the parent |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Is Parent")]
[Category("Transform/Hierarchy/Is Parent")]
[Description("Checks whether the parent of a Transform is equal to another one")]
[Image(typeof(IconHanger), ColorTheme.Type.Lime)]
[Keywords("Transform")]
[Parameter("Transform", "The Transform parent to check")]
[Parameter("Value", "The Transform to compare against the parent")]
[Serializable]
public class ConditionCoreTransformCheckParent : 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("Parent");
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.parent == this.m_Value.Get<Transform>(args);
}
}
}