UnityEditor.SpriteUtility.CreateAnimation C# (CSharp) Method

CreateAnimation() private static method

private static CreateAnimation ( GameObject gameObject, Object frames ) : bool
gameObject UnityEngine.GameObject
frames Object
return bool
        private static bool CreateAnimation(GameObject gameObject, Object[] frames)
        {
            if (<>f__am$cache0 == null)
            {
                <>f__am$cache0 = (a, b) => EditorUtility.NaturalCompare(a.name, b.name);

Usage Example

示例#1
0
 public static GameObject DropFramesToSceneToCreateGO(Sprite[] frames, Vector3 position)
 {
     if (frames.Length > 0)
     {
         Sprite sprite = frames[0];
         string name   = (!string.IsNullOrEmpty(sprite.name)) ? sprite.name : "Sprite";
         name = GameObjectUtility.GetUniqueNameForSibling(null, name);
         GameObject     gameObject     = new GameObject(name);
         SpriteRenderer spriteRenderer = gameObject.AddComponent <SpriteRenderer>();
         spriteRenderer.sprite         = sprite;
         gameObject.transform.position = position;
         Selection.activeObject        = gameObject;
         if (frames.Length > 1)
         {
             Analytics.Event("Sprite Drag and Drop", "Drop multiple sprites to scene", "null", 1);
             if (!SpriteUtility.CreateAnimation(gameObject, frames))
             {
                 UnityEngine.Object.DestroyImmediate(gameObject);
                 return(null);
             }
         }
         else
         {
             Analytics.Event("Sprite Drag and Drop", "Drop single sprite to scene", "null", 1);
         }
         return(gameObject);
     }
     return(null);
 }
All Usage Examples Of UnityEditor.SpriteUtility::CreateAnimation