43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using RPGCreationKit;
|
|||
|
|
|||
|
namespace RPGCreationKit
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Allows to have a Transform-like data without GameObjects
|
|||
|
/// </summary>
|
|||
|
[System.Serializable]
|
|||
|
public class RCKTransform
|
|||
|
{
|
|||
|
public Vector3 position = Vector3.zero;
|
|||
|
public Quaternion rotation = Quaternion.identity;
|
|||
|
|
|||
|
public RCKTransform(Vector3 _pos, Quaternion _rot)
|
|||
|
{
|
|||
|
position = _pos;
|
|||
|
rotation = _rot;
|
|||
|
}
|
|||
|
|
|||
|
public static RCKTransform Zero()
|
|||
|
{
|
|||
|
return new RCKTransform(Vector3.zero, Quaternion.identity);
|
|||
|
}
|
|||
|
|
|||
|
public static bool IsChildOfRecursive(Transform origin, Transform child, bool debug = false)
|
|||
|
{
|
|||
|
if(debug)
|
|||
|
Debug.Log(origin.name + " | " + child.name);
|
|||
|
|
|||
|
|
|||
|
if (origin.name == child.name)
|
|||
|
return true;
|
|||
|
|
|||
|
if (child.parent == null)
|
|||
|
return false;
|
|||
|
else
|
|||
|
return IsChildOfRecursive(origin, child.parent, debug);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|