Exemplo n.º 1
0
 public static void PlayForward(this UI2DSpriteAnimation mUI2DSpriteAnimation, int framesPerSecond, int frameIndex = 0, bool ignoreTimeScale = true, bool loop = false)
 {
     mUI2DSpriteAnimation.framesPerSecond = framesPerSecond;
     mUI2DSpriteAnimation.frameIndex      = frameIndex;
     mUI2DSpriteAnimation.loop            = loop;
     mUI2DSpriteAnimation.ignoreTimeScale = ignoreTimeScale;
     mUI2DSpriteAnimation.enabled         = true;
     mUI2DSpriteAnimation.ResetToBeginning();
 }
Exemplo n.º 2
0
 static public int get_loop(IntPtr l)
 {
     try {
         UI2DSpriteAnimation self = (UI2DSpriteAnimation)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.loop);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 3
0
 static public int Play(IntPtr l)
 {
     try {
         UI2DSpriteAnimation self = (UI2DSpriteAnimation)checkSelf(l);
         self.Play();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 4
0
 static public int set_loop(IntPtr l)
 {
     try {
         UI2DSpriteAnimation self = (UI2DSpriteAnimation)checkSelf(l);
         System.Boolean      v;
         checkType(l, 2, out v);
         self.loop = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 5
0
 static public int set_framesPerSecond(IntPtr l)
 {
     try {
         UI2DSpriteAnimation self = (UI2DSpriteAnimation)checkSelf(l);
         int v;
         checkType(l, 2, out v);
         self.framesPerSecond = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 6
0
 static public int set_frames(IntPtr l)
 {
     try {
         UI2DSpriteAnimation  self = (UI2DSpriteAnimation)checkSelf(l);
         UnityEngine.Sprite[] v;
         checkArray(l, 2, out v);
         self.frames = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 7
0
 static public int set_frameIndex(IntPtr l)
 {
     try {
         UI2DSpriteAnimation self = (UI2DSpriteAnimation)checkSelf(l);
         System.Int32        v;
         checkType(l, 2, out v);
         self.frameIndex = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 8
0
	public static void SetAnimations()
	{		
		currentSprite =  Selection.activeGameObject.GetComponent<UI2DSprite>();
		currentAnimation = Selection.activeGameObject.GetComponent<UI2DSpriteAnimation>();
		
		if( currentSprite == null || currentAnimation == null )
		{
			Debug.Log("Sprite ou animacao nula");
			 return;
		} 
		
		string spriteSheetPath = AssetDatabase.GetAssetPath( currentSprite.sprite2D );
		Sprite[] sprites = AssetDatabase.LoadAllAssetsAtPath(spriteSheetPath).OfType<Sprite>().ToArray();
		
		currentAnimation.AddNewAnimation( "newAnimation", sprites );
			
	}
Exemplo n.º 9
0
    public static void SetAnimations()
    {
        currentSprite    = Selection.activeGameObject.GetComponent <UI2DSprite>();
        currentAnimation = Selection.activeGameObject.GetComponent <UI2DSpriteAnimation>();

        if (currentSprite == null || currentAnimation == null)
        {
            Debug.Log("Sprite ou animacao nula");
            return;
        }

        string spriteSheetPath = AssetDatabase.GetAssetPath(currentSprite.sprite2D);

        Sprite[] sprites = AssetDatabase.LoadAllAssetsAtPath(spriteSheetPath).OfType <Sprite>().ToArray();

        currentAnimation.AddNewAnimation("newAnimation", sprites);
    }
Exemplo n.º 10
0
    void OnGUI()
    {
        NGUIEditorTools.DrawHeader("Input", true);
        NGUIEditorTools.BeginContents(false);
        GUILayout.BeginHorizontal();
        {
            ComponentSelector.Draw <Object>("Template", NGUISettings.prefabIcon, OnSelectPrefabs, true, GUILayout.MinWidth(100f));
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        bool select = GUILayout.Button("Select Icon's Folder");

        GUILayout.Space(20f);
        GUILayout.EndHorizontal();
        if (select)
        {
            string path = EditorUtility.OpenFolderPanel("Select Icon's Folder", GetString("IconFolder", string.Empty), "");
            if (!string.IsNullOrEmpty(path))
            {
                SetString("IconFolder", path);
            }
        }
        if (!string.IsNullOrEmpty(GetString("IconFolder", string.Empty)))
        {
            GUILayout.Label("Assets" + GetString("IconFolder", string.Empty).Split(new string[] { "Assets" }, 2, System.StringSplitOptions.None) [1]);
        }
        GUILayout.BeginHorizontal();
        GUILayout.Space(20f);
        GUILayout.EndHorizontal();
        bool create = GUILayout.Button("Create Icon's Prefabs");

        if (create)
        {
            //target path of icon select
            string pathToSelect = GetString("IconFolder", string.Empty);
            if (!string.IsNullOrEmpty(pathToSelect))
            {
                string[] iconsFolders = AssetPathReturn(Directory.GetDirectories(pathToSelect));// AssetDatabase.GetSubFolders(AssetPathReturn(pathToSelect));
                //target path of icon create
                string pathToCreate = EditorUtility.OpenFolderPanel("Create Icon's Prefabs", GetString("IconPrefabsFolder", "Assets/IconPrefabs"), "");
                if (!string.IsNullOrEmpty(pathToCreate))
                {
                    SetString("IconPrefabsFolder", pathToCreate);
                    for (int i = 0; i < iconsFolders.Length; i++)
                    {
                        string[] iconFilePaths = Directory.GetFiles(pathToSelect + "/" + System.IO.Path.GetFileName(iconsFolders [i]), "*.png");

                        GameObject          iconTemplate = Instantiate(NGUISettings.prefabIcon) as GameObject;
                        UI2DSpriteAnimation u2d          = iconTemplate.GetComponent <UI2DSpriteAnimation>();
                        iconTemplate.GetComponent <UI2DSprite>().sprite2D = AssetDatabase.LoadAssetAtPath(AssetPathReturn(iconFilePaths [0]), typeof(Sprite)) as Sprite;
                        u2d.frames = new Sprite[iconFilePaths.Length];


                        for (int j = 0; j < iconFilePaths.Length; j++)
                        {
                            Sprite iconSprite = AssetDatabase.LoadAssetAtPath(AssetPathReturn(iconFilePaths [j]), typeof(Sprite)) as Sprite;
                            u2d.frames.SetValue(iconSprite, j);
                        }


                        PrefabUtility.CreatePrefab(AssetPathReturn(pathToCreate) + "/" + System.IO.Path.GetFileName(iconsFolders [i]) + ".prefab", iconTemplate);
                        DestroyImmediate(iconTemplate);
                    }
                }
            }
        }
        GUILayout.BeginVertical();
        GUILayout.Space(100f);
        GUILayout.EndVertical();
        bool replace = GUILayout.Button("replace the icon's prefabs");

        if (replace)
        {
            string iconPrefabsLocation = EditorUtility.OpenFolderPanel("Select Icon's Prefabs Location", GetString("IconPrefabsFolder", "Assets/IconPrefabs"), "");
            if (!string.IsNullOrEmpty(iconPrefabsLocation))
            {
                ReplaceIconMethod(iconPrefabsLocation);
            }
        }
    }