Beispiel #1
0
 private void InitTransformRestorer()
 {
     transformRestorer = gameObject.GetComponent <TransformRestorer>();
     if (transformRestorer == null)
     {
         transformRestorer = gameObject.AddComponent <TransformRestorer>();
     }
 }
Beispiel #2
0
    private void Awake()
    {
        initialPosition = transform.position;
        initialRotation = transform.rotation;
        initialScale    = transform.localScale;
        initialChildren = new Transform[transform.childCount];
        for (int i = 0; i < initialChildren.Length; i++)
        {
            Transform         child = transform.GetChild(i);
            TransformRestorer childTransformRestorer = child.GetComponent <TransformRestorer>();
            if (childTransformRestorer == null)
            {
                child.gameObject.AddComponent <TransformRestorer>();
            }

            initialChildren[i] = child;
        }
    }
Beispiel #3
0
    public void Restore()
    {
        transform.position   = initialPosition;
        transform.rotation   = initialRotation;
        transform.localScale = initialScale;

        if (initialChildren != null)
        {
            foreach (Transform child in initialChildren)
            {
                if (child != null && child != transform)
                {
                    child.parent = transform;
                    TransformRestorer childTransformRestorer = child.GetComponent <TransformRestorer>();
                    if (childTransformRestorer != null)
                    {
                        childTransformRestorer.Restore();
                    }
                }
            }
        }
    }
Beispiel #4
0
 private void InitTransformRestorer()
 {
     transformRestorer = gameObject.AddComponent <TransformRestorer>();
 }