void OnAnimatorComplete(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { if (take.name == stats.takeDeath) { Release(); } }
static void DrawGizmos(AnimatorData aData, GizmoType gizmoType) { //check if it's the one opened if (AMTimeline.window != null && AMTimeline.window.aData != null && AMTimeline.window.aData.IsDataMatch(aData)) { AnimatorDataEdit eData = AMTimeline.AnimEdit(aData); List <AMTakeData> _t = eData.takes; if (_t == null || _t.Count == 0) { return; } if (eData.currentTakeInd < 0) { eData.currentTakeInd = 0; } else if (eData.currentTakeInd >= _t.Count) { eData.currentTakeInd = _t.Count - 1; } _t[eData.currentTakeInd].drawGizmos(eData.target, AnimatorTimeline.e_gizmoSize, Application.isPlaying); } }
void OnAnimatorComplete(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { if (take.name == takeDeactivate) { gameObject.SetActive(false); } }
void OnAnimationComplete(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { if (take.name == takeLeave || take.name == takeExplode) { Release(); } }
public void SetData(AnimatorData aData) { if (mData != aData) { mData = aData; mDataTarget = aData as AMITarget; mMetaHolder = aData as AMIMeta; mCurrentTakeInd = mPrevTakeInd = 0; } }
void OnAnimatorTakeFinish(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { if (take.name == takePumping) { isPumping = false; } else if (take.name == takeLiftoff) { isLiftingOff = false; } }
private IEnumerator Start() { if (!animator) { animator = GetComponent <M8.Animator.AnimatorData>(); } while (M8.SceneManager.instance.isLoading) { yield return(null); } animator.Play(take); }
void OnAnimatorComplete(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { if (take.name == takeEat) { if (mArms.Count > 0) { anim.Play(takeSeek); } else { anim.Play(takeNormal); } } }
void OnAnimationComplete(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { if (take.name == takeResultProceedShow) { mResultProceedActive = true; if (mRout != null) { StopCoroutine(mRout); } mRout = StartCoroutine(DoHideResultProceed()); } }
void OnAnimatorComplete(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { if (take.name == stats.data.takeSpawn) { if (!string.IsNullOrEmpty(stats.data.takeNormal)) { animator.Play(stats.data.takeNormal); } } else if (take.name == stats.data.takeDeath) { if (stats.data.releaseOnDeath) { Release(); } } }
void OnAnimatorComplete(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { if (take.name == stats.data.takeSpawn) { animator.Play(stats.data.takeNormal); } else if (take.name == stats.data.takeDeath) { if (stats.data.releaseOnDeath) { Release(); } } else if (take.name == stats.data.takeDeathInstant) { Release(); } }
void OnAnimatorComplete(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { toggleButton.raycastTarget = true; switch (GameMapController.instance.mode) { case GameMapController.Mode.Play: toggleButton.transform.localScale = new Vector3(-1f, 1f, 1f); //hide active widgets on toggle hide end for (int i = 0; i < mActiveWidgets.Count; i++) { mActiveWidgets[i].gameObject.SetActive(false); } break; case GameMapController.Mode.Edit: toggleButton.transform.localScale = new Vector3(1f, 1f, 1f); break; } }
bool saveSelectedItemsToScene() { string saveScenePath = UnityEditor.EditorUtility.SaveFilePanel("Export Take", "Assets/", (take != null ? take.name : "All_Takes"), "unity"); if (saveScenePath == "") { return(false); } // delete unselected GameObjects foreach (GameObject go in gameObjs) { if (!go) { continue; } AnimatorData dat = go.GetComponent <AnimatorData>(); if (dat) //... { if (take != null) { AnimatorDataEdit datEdit = new AnimatorDataEdit(dat); datEdit.DeleteAllTakesExcept(take); } continue; } int index = gameObjs.IndexOf(go); if (gameObjsSelected[index] != null && (bool)!gameObjsSelected[index]) { DestroyImmediate(go); } } // save with changes EditorSceneManager.SaveScene(EditorSceneManager.GetActiveScene(), saveScenePath, true); // restore scene EditorSceneManager.OpenScene(saveScenePath); // refresh project directory AssetDatabase.Refresh(); return(true); }
void OnAnimationFinish(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { if (take.name == takeSpawn) { if (mEntity) { mEntity.Follow(null); } mIsSpawning = false; } else if (take.name == takeLaunch) { //set to launch if (mEntity) { mEntity.Launch(mTarget); } mEntity = null; mTarget = null; } }
public bool IsDataMatch(AnimatorData aData) { return(aData == mData); }
public static void openAdditiveAndDeDupe(string scenePath) { List <GameObject> origGOs = ((GameObject[])GameObject.FindObjectsOfType(typeof(GameObject))).ToList(); EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Additive); List <GameObject> updGOs = ((GameObject[])GameObject.FindObjectsOfType(typeof(GameObject))).ToList(); List <GameObject> newGOs = updGOs.Except(origGOs).ToList(); // merge AnimatorData List <AnimatorDataEdit> origAnimatorData = new List <AnimatorDataEdit>(); List <AnimatorDataEdit> newAnimatorData = new List <AnimatorDataEdit>(); // get animator data foreach (GameObject go in origGOs) { AnimatorData _temp = getAnimatorData(go); if (_temp != null) { origAnimatorData.Add(new AnimatorDataEdit(_temp)); } } foreach (GameObject go in newGOs) { AnimatorData __temp = getAnimatorData(go); if (__temp != null) { newAnimatorData.Add(new AnimatorDataEdit(__temp)); } } int numTakes = 0; foreach (AnimatorDataEdit _a in newAnimatorData) { numTakes += _a.takes.Count; } int numGOs = (newGOs.Count - newAnimatorData.Count); Debug.Log("Animator: Imported " + numTakes + " Take" + (numTakes > 1 ? "s" : "") + ". Added " + numGOs + " GameObject" + (numGOs > 1 ? "s" : "") + "."); // merge new animator data together for (int i = 1; i < newAnimatorData.Count; i++) { newAnimatorData[0].MergeWith(newAnimatorData[i]); newGOs.Remove(newAnimatorData[i].gameObject); DestroyImmediate(newAnimatorData[i].gameObject); newAnimatorData.RemoveAt(i); i--; } // merge old animator data together for (int i = 1; i < origAnimatorData.Count; i++) { origAnimatorData[0].MergeWith(origAnimatorData[i]); origGOs.Remove(origAnimatorData[i].gameObject); DestroyImmediate(origAnimatorData[i].gameObject); origAnimatorData.RemoveAt(i); i--; } // merge old with new if (origAnimatorData.Count >= 1 && newAnimatorData.Count >= 1) { origAnimatorData[0].MergeWith(newAnimatorData[0]); newGOs.Remove(newAnimatorData[0].gameObject); DestroyImmediate(newAnimatorData[0].gameObject); newAnimatorData.RemoveAt(0); } // get references for new takes newReference = new List <GameObject>(); oldReference = new List <GameObject>(); // check for dupes foreach (GameObject ngo in newGOs) { if (ngo == null) { continue; } foreach (GameObject ogo in origGOs) { if (ogo == null) { continue; } if (ogo.name == ngo.name) { newReference.Add(ngo); oldReference.Add(ogo); break; } } } // open de-duper if (newReference.Count > 0) { EditorWindow windowImport = ScriptableObject.CreateInstance <AMTakeImport>(); windowImport.ShowUtility(); } }
void OnAnimationComplete(M8.Animator.AnimatorData anim, M8.Animator.AMTakeData take) { }
public override void OnInspectorGUI() { AnimatorData anim = target as AnimatorData; GUILayout.BeginVertical(); //meta AnimatorMeta curMeta = aData.meta; AnimatorMeta newMeta = EditorGUILayout.ObjectField(new GUIContent("Meta", "Use data from the reference AnimatorMeta. Note: All modifications to the animation will be saved to the Meta."), curMeta, typeof(AnimatorMeta), false) as AnimatorMeta; if (curMeta != newMeta) { bool doIt = true; if (curMeta == null) { doIt = EditorUtility.DisplayDialog("Set Meta", "Setting the Meta will replace the current animation data, proceed?", "Yes", "No"); } if (doIt) { aData.RegisterUndo("Set Meta", true); aData.MetaSet(newMeta, false); } } MetaCommand metaComm = MetaCommand.None; GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.backgroundColor = Color.green; GUI.enabled = PrefabUtility.GetPrefabType(aData.gameObject) != PrefabType.Prefab && aData.metaCanSavePrefabInstance; if (GUILayout.Button("Save", GUILayout.Width(100f))) { metaComm = MetaCommand.Save; } GUI.enabled = true; if (GUILayout.Button("Save As...", GUILayout.Width(100f))) { metaComm = MetaCommand.SaveAs; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.backgroundColor = Color.red; GUI.enabled = PrefabUtility.GetPrefabType(aData.gameObject) != PrefabType.Prefab && aData.metaCanSavePrefabInstance; if (GUILayout.Button("Revert", GUILayout.Width(100f))) { metaComm = MetaCommand.Revert; } GUI.backgroundColor = Color.white; GUI.enabled = PrefabUtility.GetPrefabType(aData.gameObject) != PrefabType.Prefab && aData.meta; if (GUILayout.Button(new GUIContent("Break", "This will copy all data from AnimatorMeta to this AnimatorData, and then removes the reference to AnimatorMeta."), GUILayout.Width(100f))) { metaComm = MetaCommand.Instantiate; } GUI.enabled = true; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); AMEditorUtil.DrawSeparator(); // List <AMTakeData> takes = aData.takes; string playTakeName = aData.defaultTakeName; int playTakeInd = 0; if (!string.IsNullOrEmpty(playTakeName)) { for (int i = 0; i < takes.Count; i++) { if (takes[i].name == aData.defaultTakeName) { playTakeInd = i + 1; break; } } } GenerateTakeLabels(); int newPlayTakeInd = EditorGUILayout.IntPopup("Play On Start", playTakeInd, mTakeLabels, null); if (newPlayTakeInd != playTakeInd) { aData.RegisterUndo("Set Play On Start", false); aData.defaultTakeName = newPlayTakeInd <= 0 ? "" : takes[newPlayTakeInd - 1].name; } bool isglobal = GUILayout.Toggle(aData.isGlobal, "Global"); if (aData.isGlobal != isglobal) { aData.RegisterUndo("Set Global", false); aData.isGlobal = isglobal; if (isglobal) { //uncheck isGlobal to any other animator data on scene AnimatorData[] anims = FindObjectsOfType <AnimatorData>(); for (int i = 0; i < anims.Length; i++) { if (!aData.IsDataMatch(anims[i]) && anims[i].isGlobal) { anims[i].isGlobal = false; } } } } anim.sequenceLoadAll = GUILayout.Toggle(anim.sequenceLoadAll, "Build All Sequence On Start"); anim.sequenceKillWhenDone = GUILayout.Toggle(anim.sequenceKillWhenDone, "Kill Sequence When Done"); anim.playOnEnable = GUILayout.Toggle(anim.playOnEnable, "Play On Enable"); anim.onDisableAction = (AnimatorData.DisableAction)EditorGUILayout.EnumPopup("On Disable", anim.onDisableAction); anim.updateType = (DG.Tweening.UpdateType)EditorGUILayout.EnumPopup("Update", anim.updateType); anim.updateTimeIndependent = EditorGUILayout.Toggle("Time Independent", anim.updateTimeIndependent); if (PrefabUtility.GetPrefabType(aData.gameObject) != PrefabType.Prefab) { AMTimeline timeline = AMTimeline.window; if (timeline != null && aData == timeline.aData) { if (GUILayout.Button("Deselect")) { timeline.aData = null; timeline.Repaint(); if (Selection.activeGameObject == aData.gameObject) { Selection.activeGameObject = null; } } } else { if (GUILayout.Button("Edit Timeline")) { if (timeline != null) { timeline.aData = aData; timeline.Repaint(); } else { EditorWindow.GetWindow(typeof(AMTimeline)); } } } } //display missings string[] missings = aData.target.GetMissingTargets(); if (missings != null && missings.Length > 0) { AMEditorUtil.DrawSeparator(); mMissingsFoldout = EditorGUILayout.Foldout(mMissingsFoldout, string.Format("Missing Targets [{0}]", missings.Length)); if (mMissingsFoldout) { for (int i = 0; i < missings.Length; i++) { GUILayout.Label(missings[i]); } } //fix missing targets if (GUILayout.Button("Generate Missing Targets")) { aData.target.GenerateMissingTargets(missings); } } GUILayout.EndVertical(); switch (metaComm) { case MetaCommand.Save: aData.MetaSaveInstantiate(); GUI.changed = true; break; case MetaCommand.SaveAs: string path = EditorUtility.SaveFilePanelInProject("Save AnimatorMeta", aData.name + ".prefab", "prefab", "Please enter a file name to save the animator data to"); if (!string.IsNullOrEmpty(path)) { GameObject metago = new GameObject("_meta"); metago.AddComponent <AnimatorMeta>(); UnityEngine.Object pref = PrefabUtility.CreateEmptyPrefab(path); GameObject metagopref = PrefabUtility.ReplacePrefab(metago, pref); UnityEngine.Object.DestroyImmediate(metago); aData.MetaSet(metagopref.GetComponent <AnimatorMeta>(), true); } break; case MetaCommand.Revert: if (EditorUtility.DisplayDialog("Revert Animator Meta", "Are you sure?", "Yes", "No")) { aData.RegisterUndo("Revert Animator Meta", true); GameObject prefabGO = PrefabUtility.GetPrefabParent(aData.meta.gameObject) as GameObject; aData.MetaSet(prefabGO ? prefabGO.GetComponent <AnimatorMeta>() : null, false); GUI.changed = true; } break; case MetaCommand.Instantiate: //warning if there are missing targets bool doIt = true; if (missings != null && missings.Length > 0) { doIt = EditorUtility.DisplayDialog("Break Animator Meta", "There are missing targets, some keys will be removed. Do you want to proceed?", "Yes", "No"); } if (doIt) { aData.RegisterUndo("Break Animator Meta", false); aData.MetaSet(null, true); aData.currentTakeInd = 0; GUI.changed = true; } break; } if (GUI.changed) { if (AMTimeline.window) { AMTimeline.window.Repaint(); } } }
public AnimatorDataEdit(AnimatorData aData) { SetData(aData); }