Пример #1
0
        static MiniTransform GetTransform(TransformBehavior behavior, string name)
        {
            Dictionary <string, MiniTransform> dictionary;

            if (!transformDictionaries.TryGetValue(behavior.GetInstanceID(), out dictionary))
            {
                dictionary = new Dictionary <string, MiniTransform>();

                for (int i = 0; i < behavior.transforms.Length; i++)
                {
                    dictionary.Add(behavior.transforms[i].name, behavior.transforms[i].transform);
                }

                transformDictionaries[behavior.GetInstanceID()] = dictionary;
            }

            MiniTransform transform;

            if (dictionary.TryGetValue(name, out transform))
            {
                return(transform);
            }

            Debug.LogWarning("Transform name " + name + " not found on Transform Behavior: " + behavior.name);
            return(null);
        }
Пример #2
0
 static MiniTransform GetTransform(TransformBehavior behavior, int index)
 {
     if (index < 0 || index >= behavior.transforms.Length)
     {
         Debug.LogWarning("Index " + index + " is out of range on Transform Behavior: " + behavior.name);
         return(null);
     }
     return(behavior.transforms[index].transform);
 }
Пример #3
0
 public static void SetTransform(this Transform transform, Transform parent, TransformBehavior behavior, int index)
 {
     transform.SetTransform(parent, GetTransform(behavior, index), behavior);
 }
Пример #4
0
 public static void SetTransform(this Transform transform, Transform parent, TransformBehavior behavior, string name)
 {
     transform.SetTransform(parent, GetTransform(behavior, name), behavior);
 }
Пример #5
0
 public static void SetTransform(this Transform transform, Transform parent, MiniTransform settings, TransformBehavior behavior)
 {
     if (settings == null)
     {
         return;
     }
     if (transform.parent != parent)
     {
         transform.SetParent(parent);
     }
     if (behavior == null || behavior.position)
     {
         transform.localPosition = settings.position;
     }
     if (behavior == null || behavior.rotation)
     {
         transform.localRotation = Quaternion.Euler(settings.rotation);
     }
     if (behavior == null || behavior.scale)
     {
         transform.localScale = settings.scale;
     }
 }