public override void OnInspectorGUI() { bool doConvert = false; base.OnInspectorGUI(); tk2dGuiUtility.InfoBox("The tk2dAnimatedSprite has been deprecated in favor of the new tk2dSpriteAnimator behaviour. " + "Using this new system will allow you to animate other kinds of sprites, etc. " + "The tk2dAnimatedSprite is now a wrapper to this system, but you can upgrade entirely to the new system " + "if you choose to", tk2dGuiUtility.WarningLevel.Warning); GUILayout.Space(8); GUI.backgroundColor = Color.red; GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Convert to SpriteAnimator", GUILayout.Width(200)) && EditorUtility.DisplayDialog("Convert to SpriteAnimator", "Converting to the SpriteAnimator system will require you to manually fix " + "all references of this tk2dSpriteAnimation.\n\n" + "Are you sure you wish to proceed?", "Yes", "No")) { doConvert = true; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; GUILayout.Space(8); if (doConvert) { Undo.RegisterSceneUndo("Convert animated sprite -> sprite animator"); foreach (Object target in targets) { tk2dAnimatedSprite animSprite = target as tk2dAnimatedSprite; if (animSprite != null) { tk2dSprite sprite = animSprite.gameObject.AddComponent <tk2dSprite>(); sprite.SetSprite(animSprite.Collection, animSprite.spriteId); sprite.color = animSprite.color; sprite.scale = animSprite.scale; // If this is not null, we assume it is already set up properly if (animSprite.GetComponent <tk2dSpriteAnimator>() == null) { tk2dSpriteAnimator spriteAnimator = animSprite.gameObject.AddComponent <tk2dSpriteAnimator>(); spriteAnimator.Library = animSprite.Library; spriteAnimator.DefaultClipId = animSprite.DefaultClipId; spriteAnimator.playAutomatically = animSprite.playAutomatically; } GameObject.DestroyImmediate(animSprite, true); EditorUtility.SetDirty(animSprite.gameObject); } } } }
public IEnumerator BurstEvent() { BurstSprite = BurstSprite.GetComponent <tk2dAnimatedSprite>(); SparkSprite = SparkSprite.GetComponent <tk2dAnimatedSprite>(); SparkSprite.Play("spark"); gameObject.rigidbody.velocity = new Vector3(0, -18f, 0); yield return(new WaitForSeconds(1.6f)); // BurstSprite.Play("burst"); // yield return new WaitForSeconds(0.5f); Destroy(gameObject); }
public void MonkeyAnimationController() { // Debug.Log("Current Props is" +PlayerPrefs.GetInt("usingProp") ); Debug.Log(PlayerPrefs.GetInt("usingProp")); switch (PlayerPrefs.GetInt("usingProp")) { case 1: leftAni.Play("Soap"); rightAni.Play("Soap"); StartCoroutine(BubbleEffect()); // BubbleEffect(); break; case 2: iTween.ScaleTo(Special[1], iTween.Hash("x", 1f, "y", 1f, "time", 0.5f)); iTween.ScaleTo(Special[0], iTween.Hash("x", 1f, "y", 1f, "time", 0.5f)); leftAni.Play("Pencil"); rightAni.Play("Pencil"); SpecialThs[0].Play("Drip"); SpecialThs[1].Play("Drip"); iTween.ScaleTo(Special[1], iTween.Hash("x", 0f, "y", 0f, "delay", 4f)); iTween.ScaleTo(Special[0], iTween.Hash("x", 0f, "y", 0f, "delay", 4f)); break; case 3: leftAni.Play("Paper"); rightAni.Play("Paper"); break; case 4: leftAni.Play("Chicken", 1f); rightAni.Play("Chicken", 1f); StartCoroutine(BoneEffect()); break; case 5: leftAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAni3; rightAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAni3; leftAni.Play("Glue"); rightAni.Play("Glue"); break; case 6: leftAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAni5; rightAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAni5; leftAni.Play("Phone"); rightAni.Play("Phone"); break; case 7: leftAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAni4; rightAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAni4; leftAni.Play("Shoes"); rightAni.Play("Shoes"); break; case 8: leftAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAni3; rightAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAni3; leftAni.Play("Ruler"); rightAni.Play("Ruler"); break; case 9: leftAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAni4; rightAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAni4; leftAni.Play("Plunger"); rightAni.Play("Plunger"); break; default: rightAni.Play("Pillow"); leftAni.Play("Pillow"); // Debug.Log("LeftAnimation Change Collection"); break; } leftAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAniDefault; rightAni.GetComponent <tk2dAnimatedSprite>().anim = MonkeyAniDefault; }