TAnim GetAnim(string n) { TAnim a = null; for (int i = 0; i < sheets.Length; i++) { if (sheets[i].name == n) { a = _anim[i]; } } return(a); }
void CreateAnimation(ref TAnim anim, string animName, AnimSprite animSheet) { TinkerAnimation[] directionAnimations = new TinkerAnimation[4] { new TinkerAnimation(), new TinkerAnimation(), new TinkerAnimation(), new TinkerAnimation() }; string[] dirs = new string[4] { "FORWARD", "RIGHT", "BACK", "LEFT" }; string gender_prefix = gender == GENDER.MALE ? "M" : "F"; string gender_name = gender == GENDER.MALE ? "Male" : "Female"; rootDirectory += itemName; string constPath = rootDirectory + gender_name; string initPath = constPath + "/" + itemName + " " + gender_prefix + "/" + animName + "/" + itemName + "_" + animName.ToUpper(); if (!AssetDatabase.IsValidFolder("Assets/" + constPath + "/" + itemName + " " + gender_prefix)) { AssetDatabase.CreateFolder("Assets/" + constPath, itemName + " " + gender_prefix); } if (!AssetDatabase.IsValidFolder("Assets/" + constPath + "/" + itemName + " " + gender_prefix + "/" + animName)) { AssetDatabase.CreateFolder("Assets/" + constPath + "/" + itemName + " " + gender_prefix, animName); } anim.anims = new TinkerAnimation[4]; // Creates animation file for each facing direction for (int i = 0; i < directionAnimations.Length; i++) { directionAnimations[i].loop = true; directionAnimations[i].timeBetweenFrames = 0.2f; directionAnimations[i].sprites = new Sprite[animSheet.frames]; // Loop through all our sprites for (int a = 0; a < animSheet.frames; a++) { directionAnimations[i].sprites[a] = animSheet.sprite[i + (a * 4)]; } ScriptableObjectUtility.CreateAsset <TinkerAnimation>(directionAnimations[i], initPath + "ANIM_" + gender_prefix + "_" + dirs[i]); //anim.anims[i] = (TinkerAnimation)Resources.Load(initPath + "ANIM_"+ gender_prefix + "_" + dirs[i]); anim.anims[i] = directionAnimations[i]; } ScriptableObjectUtility.CreateAsset <TAnim>(anim, initPath + "_" + gender_prefix); AssetDatabase.Refresh(); }
void OnWizardCreate() { if (itemName == "") { return; } TAnim[] _anim = new TAnim[sheets.Length]; for (int i = 0; i < sheets.Length; i++) { _anim[i] = new TAnim(); CreateAnimation(ref _anim[i], sheets[i].name, sheets[i].sprite); } }
void CreateAnimation(ref TAnim anim, string animName, AnimSprite animSheet) { TinkerAnimation[] directionAnimations = new TinkerAnimation[4] { new TinkerAnimation(), new TinkerAnimation(), new TinkerAnimation(), new TinkerAnimation() }; string[] dirs = new string[4] { "FORWARD", "RIGHT", "BACK", "LEFT" }; string finalPath = ""; if (groupName.Length > 0) { finalPath = rootDirectory + "/" + groupName + "/" + animName; } else { finalPath = rootDirectory + "/" + animName; } if (!AssetDatabase.IsValidFolder("Assets/" + rootDirectory)) { AssetDatabase.CreateFolder("Assets", rootDirectory); } if (groupName.Length > 0) { if (!AssetDatabase.IsValidFolder("Assets/" + rootDirectory + "/" + groupName)) { AssetDatabase.CreateFolder("Assets/" + rootDirectory, groupName); } if (!AssetDatabase.IsValidFolder("Assets/" + rootDirectory + "/" + groupName + "/" + animName)) { AssetDatabase.CreateFolder("Assets/" + rootDirectory + "/" + groupName, animName); } } else { if (!AssetDatabase.IsValidFolder("Assets/" + rootDirectory + "/" + animName)) { AssetDatabase.CreateFolder("Assets/" + rootDirectory, animName); } } anim.anims = new TinkerAnimation[4]; // Creates animation file for each facing direction for (int i = 0; i < directionAnimations.Length; i++) { directionAnimations[i].loop = animSheet.loop; directionAnimations[i].timeBetweenFrames = 0.2f; directionAnimations[i].sprites = new Sprite[animSheet.frames]; // Loop through all our sprites for (int a = 0; a < animSheet.frames; a++) { directionAnimations[i].sprites[a] = animSheet.sprite[i + (a * 4)]; } ScriptableObjectUtility.CreateAsset <TinkerAnimation>(directionAnimations[i], finalPath + "/ANIM_" + itemName + "_" + dirs[i]); //anim.anims[i] = (TinkerAnimation)Resources.Load(initPath + "ANIM_"+ gender_prefix + "_" + dirs[i]); anim.anims[i] = directionAnimations[i]; } ScriptableObjectUtility.CreateAsset <TAnim>(anim, finalPath + "/" + itemName + "_" + animName); AssetDatabase.Refresh(); }