Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - zhaoqingqing

Pages: [1]
1
Support / Re: Create Sprite Animation With Code
« on: April 30, 2014, 02:35:52 am »
OK, I understand ,thanks you !

2
Support / Create Sprite Animation With Code
« on: April 29, 2014, 09:52:59 am »
Hello Unikron,Our team is doing packed images and Use scripts to automate generate sprite Animation script  but not success
Here is my script
Code: [Select]
[MenuItem("Game/AutoCreate Sprite Animation")]
public static void CreateSpriteAnimaTest()
{
//sprite animation
string animaSpPath = "Assets/Actor/ActorAnimation.prefab";
tk2dSpriteAnimation newSpriteAnimation = null;//
if (animaSpPath.Length != 0)
{
GameObject go = new GameObject();
newSpriteAnimation = go.AddComponent<tk2dSpriteAnimation>();
tk2dEditorUtility.SetGameObjectActive(go, false);
UnityEngine.Object p = PrefabUtility.CreateEmptyPrefab(animaSpPath);
PrefabUtility.ReplacePrefab(go, p, ReplacePrefabOptions.ConnectToPrefab);
//GameObject.DestroyImmediate(go);
tk2dEditorUtility.GetOrCreateIndex().AddSpriteAnimation(AssetDatabase.LoadAssetAtPath(animaSpPath, typeof(tk2dSpriteAnimation)) as tk2dSpriteAnimation);

tk2dEditorUtility.CommitIndex();

//AnimationEditorPopup
tk2dSpriteAnimationEditorPopup editor = EditorWindow.GetWindow(typeof(tk2dSpriteAnimationEditorPopup), false, "Sprite Animation") as tk2dSpriteAnimationEditorPopup;
editor.CreateNewClip();

CBase.Log("new clip");
editor.SetSpriteAnimation(newSpriteAnimation);

//AutoFillFrames.

editor.Commit();
editor.Close();
}
}
However, the script did not like my expectations, it also creates SpriteAnimation, but SpriteAnimation is empty, Does not contain any  NewClip,
ask for help

Pages: [1]