void Awake() { if (target == null) { target = GetComponent <AnimatorData>(); } }
public void reloadAnimatorData() { aData = null; loadAnimatorData(); AMTake take = aData.getCurrentTake(); // update references for track and key bool shouldClose = true; foreach (AMTrack _track in take.trackValues) { if (track == _track) { track = _track; foreach (AMKey _key in track.keys) { if (key == _key) { key = _key; shouldClose = false; } } } } if (shouldClose) { this.Close(); } }
void AnimCompleted(AnimatorData dat, AMTake _take) { if (repeat && !mStopped) { Invoke("DoPlay", repeatDelay); } }
protected override void Awake() { base.Awake(); mAnimDat = GetComponent <AnimatorData>(); mTurretInds = new int[turrets.Length]; for (int i = 0; i < mTurretInds.Length; i++) { mTurretInds[i] = i; } mTurretAliveCount = turrets.Length; panicActiveGO.SetActive(false); mPanicCurProjs = new Projectile[panicProjMaxCount]; mPanicProjPts = new Transform[panicProjPtsHolder.childCount]; for (int i = 0; i < mPanicProjPts.Length; i++) { mPanicProjPts[i] = panicProjPtsHolder.GetChild(i); } M8.ArrayUtil.Shuffle(mPanicProjPts); }
public void PlayOnce() { this.gameObject.SetActive(true); if (aniController != null) { aniController.AniName = ChangeAni; } foreach (ParticleSystem ps in pss) { ps.loop = false; ps.Play(false); } foreach (Animation an in anis) { an.wrapMode = WrapMode.Once; an.Play(); } StopAnimitor(false); for (int i = 0; i < mAnimators.Length; i++) { AnimatorData aniData = mAnimators[i]; StartCoroutine(WaitAndPlay(aniData)); } foreach (ParticleAndAnimation paa in paas) { if (paa != null) { paa.PlayOnce(); } } }
public void PlayLoop() { if (isPlaying) { return; } isPlaying = true; this.gameObject.SetActive(true); StopAnimitor(false); foreach (ParticleSystem ps in pss) { ps.loop = true; ps.Play(false); } foreach (Animation an in anis) { an.wrapMode = WrapMode.Loop; an.Play(); } for (int i = 0; i < mAnimators.Length; i++) { AnimatorData aniData = mAnimators[i]; StartCoroutine(WaitAndPlay(aniData)); } foreach (ParticleAndAnimation paa in paas) { paa.PlayLoop(); } }
//protected Animator myAnimator; // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { // myAnimator = animator; //} public virtual AnimatorData GetData(Animator myAnimator) { AnimatorData currentStateData = Instantiate((AnimatorData)GameManager.instance.GetDataReference(GameManager.DataType.t_AnimatorData)); currentStateData.Moving = false; return(currentStateData); }
void Awake() { mAnim = GetComponent <AnimatorData>(); mSprite = GetComponent <UISprite>(); mEmptyRef = mSprite.spriteName; }
public static void LoadAssets() { var anim = new AnimatorData("entities_16_16"); anim.Add("idle", AnimatorMode.Loop, 0.2f, 240, 241, 242, 243, 244, 245, 246, 247); Asset.AddAnimatorData("projectile", anim); }
public void Stop() { isPlaying = false; //public string ChangeStopAni; //public lfAniController aniController; if (aniController != null) { aniController.AniName = ChangeStopAni; } foreach (ParticleSystem ps in pss) { ps.Stop(false); ps.Clear(false); } foreach (Animation an in anis) { an.Stop(); } for (int i = 0; i < mAnimators.Length; i++) { AnimatorData data = mAnimators[i]; //aniData.ani.StopPlayback(); if (!string.IsNullOrEmpty(data.stateName)) { data.ani.SetBool(data.stateName, false); } } foreach (ParticleAndAnimation paa in paas) { paa.Stop(); } this.gameObject.SetActive(false); }
public bool Click(tk2dSpriteAnimator animSpr, AnimatorData toPlay, string take) { if (mIsFinalLevel) { //if unlocked, load level if (finalActiveGO.activeSelf) { Main.instance.sceneManager.LoadScene(Scenes.finalStages); return(true); } } else { if (inactive.activeSelf) { Main.instance.sceneManager.LoadScene(level); return(true); } else { //start intro UIModalManager.instance.ModalCloseAll(); animSpr.Library = animRef; LevelSelectCharacterControl.instance.toScene = level; LevelSelectCharacterControl.instance.SetAnimWatch(toPlay); toPlay.Play(take); return(true); } } return(false); }
public void mergeWith(AnimatorData _aData) { foreach (AMTake take in _aData.takes) { takes.Add(take); makeTakeNameUnique(take); } }
public override void SpawnFinish() { AnimatorData animDat = target ? target : GetComponent <AnimatorData>(); animDat.takeCompleteCallback += OnAnimationComplete; base.SpawnFinish(); }
void OnDisable() { window = null; justSet = false; key = null; track = null; aData = null; }
void loadAnimatorData() { aData = AMTimeline.GetAnimatorData(); //GameObject go = GameObject.Find ("AnimatorData"); //if(go) { // aData = (AnimatorData) go.GetComponent<AnimatorData>(); //} }
public static void LoadAssets() { var anim = new AnimatorData("gfx/bat", 24, 24); anim.Add("idle", AnimatorMode.Loop, 0.5f, 0, 1); anim.Add("attack", AnimatorMode.OneShot, 0.25f, 2, 3); Asset.AddAnimatorData("bat", anim); }
void loadAnimatorData() { GameObject go = GameObject.Find("AnimatorData"); if (go) { aData = (AnimatorData)go.GetComponent("AnimatorData"); } }
void Awake() { if (animDat == null) { animDat = GetComponent <AnimatorData>(); } animDat.takeCompleteCallback += AnimCompleted; }
public override AnimatorData GetData(Animator myAnimator) { AnimatorData currentStateData = Object.Instantiate((AnimatorData)GameManager.instance.GetDataReference(GameManager.DataType.t_AnimatorData)); currentStateData.X = myAnimator.GetFloat("MoveX"); currentStateData.Y = myAnimator.GetFloat("MoveY"); currentStateData.Moving = false; return(currentStateData); }
public static void LoadAssets() { var anim = new AnimatorData("entities_16_16"); anim.Add("KeyA", 68); anim.Add("KeyB", 72); anim.Add("KeyC", 76); Asset.AddAnimatorData("ui_item", anim); }
private EntityData AddAnim(string name, AnimatorMode mode, float interval, params int[] frames) { if (Anim == null) { Anim = new AnimatorData("entities_16_16"); } Anim.Add(name, mode, interval, frames); return(this); }
void loadAnimatorData() { GameObject go = GameObject.Find ("AnimatorData"); if(go) { aData = (AnimatorData) go.GetComponent ("AnimatorData"); numFrames = aData.getCurrentTake().numFrames; frameRate = aData.getCurrentTake().frameRate; } }
protected override void Awake() { base.Awake(); mPlayer = Player.instance; mAnimDat = GetComponent <AnimatorData>(); moveAttackTrigger.SetActive(false); }
public void SaveAsset(AnimatorData mb, AMTake take) { AMTakeSav.AddObjectToAsset(this, take); for (int i = 0; i < lsArray.Count; ++i) { var p = lsArray[i]; p.SaveAsset(mb, take); } }
void loadAnimatorData() { if(AMTimeline.window) { aData = AMTimeline.window.aData; dependencies = aData.getDependencies(take); } else { this.Close(); } }
void loadAnimatorData() { GameObject go = GameObject.Find ("AnimatorData"); if(go) { aData = (AnimatorData) go.GetComponent ("AnimatorData"); dependencies = aData.getDependencies(take); } else { this.Close(); } }
public static AnimatorData getAnimatorData(GameObject go) { if (go.name != "AnimatorData") { return(null); } AnimatorData __aData = (AnimatorData)go.GetComponent <AnimatorData>(); return(__aData); }
void loadAnimatorData() { GameObject go = GameObject.Find("AnimatorData"); if (go) { aData = (AnimatorData)go.GetComponent("AnimatorData"); numFrames = aData.getCurrentTake().numFrames; frameRate = aData.getCurrentTake().frameRate; } }
void loadAnimatorData() { if(AMTimeline.window) { __aData = AMTimeline.window.aData; if(track) { _go = track.obj; // refresh updateComponentArray(); } } }
public void CollectStar(Collider col) { col.enabled = false; AnimatorData anim = col.GetComponent <AnimatorData>(); anim.Play("collect"); mLastStarsCollected.Add(anim); mHUD.StarFill(); }
IEnumerator DoConvertAnimator(AnimatorData animData, string assetPath) { var go = animData.gameObject; Animate newAnim; newAnim = go.AddComponent <Animate>(); var newAnimTarget = newAnim as ITarget; var oldAnimTarget = animData as AMITarget; //fill in common data newAnim.sequenceLoadAll = animData.sequenceLoadAll; newAnim.sequenceKillWhenDone = animData.sequenceKillWhenDone; newAnim.playOnEnable = animData.playOnEnable; newAnim.isGlobal = animData.isGlobal; newAnim.onDisableAction = (Animate.DisableAction)((int)animData.onDisableAction); newAnim.updateType = animData.updateType; newAnim.updateTimeIndependent = animData.updateTimeIndependent; if (oldAnimTarget.isMeta) { var oldMetaTarget = animData as AMIMeta; var oldMetaPath = AssetDatabase.GetAssetPath(oldMetaTarget.meta); var oldMetaGUID = AssetDatabase.AssetPathToGUID(oldMetaPath); //grab matching meta for new anim., no need to construct takes MetaInfo metaInfo; if (mGUIDMetaMatch.TryGetValue(oldMetaGUID, out metaInfo)) { newAnimTarget.meta = metaInfo.meta; } else { AddMessage("Unable to find matching meta for: " + oldMetaPath, Color.yellow); } } else { //construct and convert takes foreach (var oldTake in oldAnimTarget.takes) { var newTake = new Take(); AddMessage(" - convert take: " + oldTake.name); yield return(EditorCoroutines.StartCoroutine(DoConvertTake(oldTake, newTake, false, assetPath), this)); newAnimTarget.takes.Add(newTake); } } newAnim.defaultTakeName = animData.defaultTakeName; }
void loadAnimatorData() { if(AMTimeline.window) { __aData = AMTimeline.window.aData; numFrames = __aData.getCurrentTake().numFrames; frameRate = __aData.getCurrentTake().frameRate; loopCount = __aData.getCurrentTake().numLoop; loopMode = __aData.getCurrentTake().loopMode; loopBackFrame = __aData.getCurrentTake().loopBackToFrame; } }
public static void LoadAssets() { Asset.AddPixelMaskSet("tileset", "mask/tileset", Global.TileSize, Global.TileSize); var anim = new AnimatorData("gfx/game/tileset", 16, 16); anim.Add("Left", AnimatorMode.Loop, 0.2f, 224, 225, 226, 227); anim.Add("Right", AnimatorMode.Loop, 0.2f, 240, 241, 242, 243); anim.Add("Up", AnimatorMode.Loop, 0.2f, 192, 193, 194, 195); anim.Add("Down", AnimatorMode.Loop, 0.2f, 208, 209, 210, 211); Asset.AddAnimatorData("torch", anim); }
void OnTakeFinish(AnimatorData anim, AMTakeData take) { if (take.name == mOverrideTake) { mOverrideTake = null; } if (takeFinishCallback != null) { takeFinishCallback(this, anim, take); } }
public override void SaveAsset(AnimatorData mb, AMTake take) { base.SaveAsset(mb, take); if (parameters != null) { for (int i = 0; i < parameters.Count; ++i) { var p = parameters[i]; AMTakeSav.AddObjectToAsset(p, take); } } }
void loadAnimatorData() { GameObject go = GameObject.Find ("AnimatorData"); if(go) { aData = (AnimatorData) go.GetComponent ("AnimatorData"); if(track) { _go = track.obj; // refresh updateComponentArray(); } } }
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); } }
public void Click(tk2dSpriteAnimator animSpr, AnimatorData toPlay, string take) { if(mIsFinalLevel) { //if unlocked, load level } else { if(inactive.activeSelf) { Main.instance.sceneManager.LoadScene(level); } else { //start intro UIModalManager.instance.ModalCloseAll(); animSpr.Library = animRef; LevelSelectCharacterControl.instance.toScene = level; LevelSelectCharacterControl.instance.SetAnimWatch(toPlay); toPlay.Play(take); } } }
public void SetData(AnimatorData aData) { if(mData != aData) { mData = aData; mDataTarget = aData as AMITarget; mMetaHolder = aData as AMIMeta; mCurrentTakeInd = mPrevTakeInd = 0; } }
public AnimatorDataEdit(AnimatorData aData) { SetData(aData); }
void loadAnimatorData() { GameObject go = GameObject.Find ("AnimatorData"); if(go) { aData = (AnimatorData) go.GetComponent ("AnimatorData"); } }
void loadAnimatorData() { if(AMTimeline.window != null) { __aData = AMTimeline.window.aData; if(__aData) { if(__aData.playOnStart != null) playOnStartIndex = __aData.getTakeIndex(__aData.playOnStart) + 1; exportTakeIndex = __aData.getTakeIndex(__aData.getCurrentTake()); } } }
public void reloadAnimatorData() { aData = null; loadAnimatorData(); }
public void SetAnimWatch(AnimatorData animDat) { animDat.takeCompleteCallback += OnAnimationEnd; }
public void mergeWith(AnimatorData _aData) { foreach(AMTake take in _aData.takes) { takes.Add(take); makeTakeNameUnique(take); } }
void OnGUI() { /*if(Event.current.type != EventType.Repaint && Event.current.type != EventType.Layout) { Debug.Log("event type: " + Event.current.type); }*/ if(!oData) { oData = AMOptionsFile.loadFile(); } AMTimeline.loadSkin(oData, ref skin, ref cachedSkinName, position); if(EditorApplication.isPlayingOrWillChangePlaymode) { this.ShowNotification(new GUIContent("Play Mode")); return; } if(EditorApplication.isCompiling) { this.ShowNotification(new GUIContent("Code Compiling")); return; } #region no data component if(!aData) { // recheck for component GameObject go = Selection.activeGameObject; if(go) { if(PrefabUtility.GetPrefabType(go) != PrefabType.Prefab) { aData = go.GetComponent<AnimatorData>(); } else go = null; } if(!aData) { // no data component message if(go) MessageBox("Animator requires an AnimatorData component in your game object.", MessageBoxType.Info); else MessageBox("Animator requires an AnimatorData in scene.", MessageBoxType.Info); if(GUILayout.Button(go ? "Add Component" : "Create AnimatorData")) { // create component if(!go) go = new GameObject("AnimatorData"); aData = go.AddComponent<AnimatorData>(); } } if(!aData) //still no data return; } /*else { if(!aData.CheckNulls()) { aData = null; Repaint(); return; } }*/ if(!aData.getCurrentTake()) { Repaint(); return; } //???? //retain animator open, this is mostly when recompiling AnimatorData aData.isAnimatorOpen = true; #endregion #region window resize if(!oData.ignoreMinSize && (position.width < width_window_minimum)) { MessageBox("Window is too small! Animator requires a width of at least " + width_window_minimum + " pixels to function correctly.", MessageBoxType.Warning); GUILayout.BeginHorizontal(); if(GUILayout.Button("Ignore (Not Recommended)")) { oData.ignoreMinSize = true; // save EditorUtility.SetDirty(aData); // repaint this.Repaint(); } if(GUILayout.Button("Resize")) { Rect rectDimensions = position; rectDimensions.width = width_window_minimum + 1f; position = rectDimensions; GUIUtility.ExitGUI(); } GUILayout.EndHorizontal(); return; } #endregion if(tickerSpeed <= 0) tickerSpeed = 1; ticker = (ticker + 1) % tickerSpeed; EditorGUIUtility.LookLikeControls(); // reset mouse over element mouseOverElement = (int)ElementType.None; mouseOverFrame = 0; mouseXOverFrame = 0; mouseOverTrack = -1; mouseOverGroupElement = new Vector2(0, 0); tooltip = ""; int difference = 0; //if(oData.disableTimelineActions) current_height_frame = height_track; //else current_height_frame = height_frame; if(oData.disableTimelineActions) height_action_min = 0f; else height_action_min = 45f; #region temporary variables Rect rectWindow = new Rect(0f, 0f, position.width, position.height); Event e = Event.current; // get global mouseposition Vector2 globalMousePosition = getGlobalMousePosition(e); // resize track if(dragType == (int)DragType.ResizeTrack) { aData.width_track = startResize_width_track + e.mousePosition.x - startScrubMousePosition.x; } width_track = Mathf.Clamp(aData.width_track, width_track_min, position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) - width_playback_controls - 70f); if(aData.width_track != width_track) aData.width_track = width_track; bool compact = ((oData.ignoreMinSize) && (position.width < width_window_minimum)); // when true, display compact GUI currentMousePosition = e.mousePosition; bool clickedZoom = false; #endregion #region drag logic events bool wasDragging = false; if(e.type == EventType.mouseDrag && EditorWindow.mouseOverWindow == this) { isDragging = true; } else if((dragType == (int)DragType.CursorZoom && EditorWindow.mouseOverWindow != this) || e.type == EventType.mouseUp || /*EditorWindow.mouseOverWindow!=this*/Event.current.rawType == EventType.MouseUp /*|| e.mousePosition.y < 0f*/) { if(isDragging) { wasDragging = true; isDragging = false; } } #endregion #region keyboard events if(e.Equals(Event.KeyboardEvent("[enter]")) || e.Equals(Event.KeyboardEvent("return"))) { // apply renaming when pressing enter cancelTextEditting(); if(isChangingTimeControl) isChangingTimeControl = false; if(isChangingFrameControl) isChangingFrameControl = false; // deselect keyboard focus GUIUtility.keyboardControl = 0; GUIUtility.ExitGUI(); } // check if control or shift are down isControlDown = e.control || e.command; isShiftDown = e.shift; if(e.type == EventType.keyDown && e.keyCode == KeyCode.Space) isSpaceBarDown = true; else if(e.type == EventType.keyUp && e.keyCode == KeyCode.Space) isSpaceBarDown = false; #endregion #region set cursor int customCursor = (int)CursorType.None; bool showCursor = true; if(!isRenamingTake && isRenamingGroup >= 0 && isRenamingTrack <= -1 && (dragType == (int)DragType.CursorHand || (!cursorZoom && isSpaceBarDown && EditorWindow.mouseOverWindow == this))) { cursorHand = true; showCursor = false; customCursor = (int)CursorType.Hand; mouseOverElement = (int)ElementType.CursorHand; // unused button to catch clicks GUI.Button(rectWindow, "", "label"); } else if(dragType == (int)DragType.CursorZoom || (!cursorHand && e.alt && EditorWindow.mouseOverWindow == this)) { cursorZoom = true; showCursor = false; customCursor = (int)CursorType.Zoom; if(!isDragging) { if(isControlDown) tex_cursor_zoom = tex_cursor_zoomout; else tex_cursor_zoom = tex_cursor_zoomin; } mouseOverElement = (int)ElementType.CursorZoom; if(!wasDragging) { if(GUI.Button(rectWindow, "", "label")) { if(isControlDown) { if(aData.zoom < 1f) { aData.zoom += 0.2f; if(aData.zoom > 1f) aData.zoom = 1f; clickedZoom = true; } } else { if(aData.zoom > 0f) { aData.zoom -= 0.2f; if(aData.zoom < 0f) aData.zoom = 0f; clickedZoom = true; } } } } } else { if(!showCursor) showCursor = true; cursorHand = false; cursorZoom = false; } if(Screen.showCursor != showCursor) { Screen.showCursor = showCursor; } if(isRenamingTake || isRenamingTrack != -1 || isRenamingGroup < 0) EditorGUIUtility.AddCursorRect(rectWindow, MouseCursor.Text); else if(dragType == (int)DragType.TimeScrub || dragType == (int)DragType.FrameScrub || dragType == (int)DragType.MoveSelection) EditorGUIUtility.AddCursorRect(rectWindow, MouseCursor.SlideArrow); else if(dragType == (int)DragType.ResizeTrack || dragType == (int)DragType.ResizeAction || dragType == (int)DragType.ResizeHScrollbarLeft || dragType == (int)DragType.ResizeHScrollbarRight) EditorGUIUtility.AddCursorRect(rectWindow, MouseCursor.ResizeHorizontal); #endregion #region calculations processHandDragAcceleration(); // calculate number of frames to render calculateNumFramesToRender(clickedZoom, e); //current_height_frame = (oData.disableTimelineActions ? height_track : height_frame); // if is playing, disable all gui elements GUI.enabled = !(isPlaying); // if selected frame is out of range if(aData.getCurrentTake().selectedFrame > aData.getCurrentTake().numFrames) { // select last frame timelineSelectFrame(aData.getCurrentTake().selectedTrack, aData.getCurrentTake().numFrames); } // get number of tracks in current take, use for tracks and keys, disabling zoom slider int trackCount = aData.getCurrentTake().getTrackCount(); #endregion #region menu bar GUIStyle styleLabelMenu = new GUIStyle(EditorStyles.toolbarButton); styleLabelMenu.normal.background = null; //GUI.color = new Color(190f/255f,190f/255f,190f/255f,1f); GUI.DrawTexture(new Rect(0f, 0f, position.width, height_menu_bar - 2f), EditorStyles.toolbar.normal.background); //GUI.color = Color.white; #region select name GUIContent selectLabel = new GUIContent(aData.gameObject.name); Vector2 selectLabelSize = EditorStyles.toolbarButton.CalcSize(selectLabel); Rect rectSelectLabel = new Rect(margin, 0f, selectLabelSize.x, height_button_delete); if(GUI.Button(rectSelectLabel, selectLabel, EditorStyles.toolbarButton)) { EditorGUIUtility.PingObject(aData.gameObject); } #endregion #region options button Rect rectBtnOptions = new Rect(rectSelectLabel.x + rectSelectLabel.width + margin, 0f, 60f, height_button_delete); if(GUI.Button(rectBtnOptions, "Options", EditorStyles.toolbarButton)) { EditorWindow windowOptions = ScriptableObject.CreateInstance<AMOptions>(); //windowOptions.Show(); windowOptions.ShowUtility(); //EditorWindow.GetWindow (typeof (AMOptions)); } if(rectBtnOptions.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) mouseOverElement = (int)ElementType.Button; #endregion #region refresh button bool doRefresh = false; Rect rectBtnCodeView = new Rect(rectBtnOptions.x + rectBtnOptions.width + margin, rectBtnOptions.y, 80f, rectBtnOptions.height); if(GUI.Button(rectBtnCodeView, "Refresh", EditorStyles.toolbarButton)) { //EditorWindow.GetWindow(typeof(AMCodeView)); doRefresh = true; } if(rectBtnCodeView.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Button; } #endregion #region take popup, change take or create new take Rect rectLabelCurrentTake = new Rect(rectBtnCodeView.x, rectBtnCodeView.y, rectBtnCodeView.width, rectBtnCodeView.height); if(!compact) { rectLabelCurrentTake = new Rect(rectBtnCodeView.x + rectBtnCodeView.width + margin, rectBtnCodeView.y, 80f, rectBtnCodeView.height); GUI.Label(rectLabelCurrentTake, "Current Take:", styleLabelMenu); } Rect rectTakePopup = new Rect(rectLabelCurrentTake.x + rectLabelCurrentTake.width + margin, rectLabelCurrentTake.y/*+3f*/, width_take_popup, 20f); // if renaming take, show textfield if(isRenamingTake) { GUI.SetNextControlName("RenameTake"); Rect rectRenameTake = new Rect(rectTakePopup); rectRenameTake.x += 4f; rectRenameTake.width -= 4f; rectRenameTake.y += 3f; aData.getCurrentTake().name = GUI.TextField(rectRenameTake, aData.getCurrentTake().name, EditorStyles.toolbarTextField); GUI.FocusControl("RenameTake"); } else { // show popup if(aData.setCurrentTakeValue(EditorGUI.Popup(rectTakePopup, aData.currentTake, aData.getTakeNames(), EditorStyles.toolbarPopup))) { // take changed // reset code view dictionaries AMCodeView.resetTrackDictionary(); // if not creating new take if(aData.currentTake < aData.takes.Count) { // select current frame timelineSelectFrame(aData.getCurrentTake().selectedTrack, aData.getCurrentTake().selectedFrame); // save data EditorUtility.SetDirty(aData); } } } #endregion #region rename take button Texture texRenameTake; if(isRenamingTake) texRenameTake = getSkinTextureStyleState("accept").background; else texRenameTake = getSkinTextureStyleState("rename").background; Rect rectBtnRenameTake = new Rect(rectTakePopup.x + rectTakePopup.width + margin, rectLabelCurrentTake.y, width_button_delete, height_button_delete); // button if(GUI.Button(rectBtnRenameTake, new GUIContent(texRenameTake, (isRenamingTake ? "Accept" : "Rename Take")),/*GUI.skin.GetStyle("ButtonImage")*/EditorStyles.toolbarButton)) { if(!isRenamingTake) Undo.RecordObject(aData.getCurrentTake(), "Rename Take"); GUIUtility.keyboardControl = 0; cancelTextEditting(true); // toggle isRenamingTake EditorUtility.SetDirty(aData.getCurrentTake()); } if(rectBtnRenameTake.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) mouseOverElement = (int)ElementType.Button; #endregion #region delete take button Rect rectBtnDeleteTake = new Rect(rectBtnRenameTake.x + rectBtnRenameTake.width + margin, rectBtnRenameTake.y, width_button_delete, height_button_delete); if(GUI.Button(rectBtnDeleteTake, new GUIContent("", "Delete Take"),/*GUI.skin.GetStyle("ButtonImage")*/EditorStyles.toolbarButton)) { AMTake take = aData.getCurrentTake(); if((EditorUtility.DisplayDialog("Delete Take", "Are you sure you want to delete take '" + take.name + "'?", "Delete", "Cancel"))) { string label = "Delete Take: "+take.name; Undo.RegisterCompleteObjectUndo(aData, label); if(aData.takes.Count == 1) { Undo.RecordObject(take, label); MonoBehaviour[] behaviours = getKeysAndTracks(take); //just delete the tracks and keys foreach(MonoBehaviour b in behaviours) Undo.DestroyObjectImmediate(b); take.RevertToDefault(); EditorUtility.SetDirty(take); } else { if(take == aData.playOnStart) aData.playOnStart = null; if(aData.currentTake > 0) aData.currentTake--; List<AMTake> nTakes = new List<AMTake>(aData.takes); nTakes.Remove(take); aData.takes = nTakes; MonoBehaviour[] behaviours = getKeysAndTracks(take); foreach(MonoBehaviour b in behaviours) Undo.DestroyObjectImmediate(b); Undo.DestroyObjectImmediate(take); } AMCodeView.resetTrackDictionary(); // save data EditorUtility.SetDirty(aData); } } if(!GUI.enabled) GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.25f); GUI.DrawTexture(new Rect(rectBtnDeleteTake.x + (rectBtnDeleteTake.height - 10f) / 2f, rectBtnDeleteTake.y + (rectBtnDeleteTake.width - 10f) / 2f - 2f, 10f, 10f), (getSkinTextureStyleState((GUI.enabled && rectBtnDeleteTake.Contains(e.mousePosition) ? "delete_hover" : "delete")).background)); if(rectBtnDeleteTake.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) mouseOverElement = (int)ElementType.Button; if(GUI.color.a < 1f) GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 1f); #endregion #region Create/Duplicate Take if(aData.currentTake == aData.takes.Count) { isRenamingTake = false; cancelTextEditting(); aData.currentTake = aData.takes.Count - 1; // decrement for undo string label = "New Take"; Undo.RecordObject(aData, label); aData.currentTake = aData.takes.Count; AMTake newTake = aData.addTake(); Undo.RegisterCreatedObjectUndo(newTake, label); // save data EditorUtility.SetDirty(aData); // refresh component refreshGizmos(); } else if(aData.currentTake == aData.takes.Count + 1) { isRenamingTake = false; cancelTextEditting(); aData.currentTake = aData.takes.Count - 1; // decrement for undo string label = "New Duplicate Take"; Undo.RecordObject(aData, label); AMTake prevTake = aData.getPreviousTake(); //if(takes == null || currentTake >= takes.Count) return null; if(prevTake != null) { List<UnityEngine.Object> ret = aData.duplicateTake(prevTake); foreach(UnityEngine.Object newObj in ret) Undo.RegisterCreatedObjectUndo(newObj, label); } else { AMTake newTake = aData.addTake(); Undo.RegisterCreatedObjectUndo(newTake, label); } aData.currentTake = aData.takes.Count - 1; // save data EditorUtility.SetDirty(aData); } #endregion #region play on start button Rect rectBtnPlayOnStart = new Rect(rectBtnDeleteTake.x + rectBtnDeleteTake.width + margin, rectBtnDeleteTake.y, width_button_delete, height_button_delete); bool isPlayOnStart = aData.playOnStart == aData.getCurrentTake(); GUIStyle styleBtnPlayOnStart = new GUIStyle(/*GUI.skin.GetStyle("ButtonImage")*/EditorStyles.toolbarButton); if(isPlayOnStart) { styleBtnPlayOnStart.normal.background = styleBtnPlayOnStart.onNormal.background; styleBtnPlayOnStart.hover.background = styleBtnPlayOnStart.onNormal.background; } if(GUI.Button(rectBtnPlayOnStart, new GUIContent(getSkinTextureStyleState("playonstart").background, "Play On Start"), styleBtnPlayOnStart)) { if(!isPlayOnStart) aData.playOnStart = aData.getCurrentTake(); else aData.playOnStart = null; EditorUtility.SetDirty(aData); } #endregion #region settings Rect rectLabelSettings = new Rect(rectBtnPlayOnStart.x + rectBtnPlayOnStart.width + margin, rectBtnPlayOnStart.y, 200f, rectLabelCurrentTake.height); if(compact) { rectLabelSettings.width = GUI.skin.label.CalcSize(new GUIContent("Settings")).x; GUI.Label(rectLabelSettings, "Settings", styleLabelMenu); } else { string strSettings = "Settings: " + aData.getCurrentTake().numFrames + " Frames; " + aData.getCurrentTake().frameRate + " Fps"; rectLabelSettings.width = GUI.skin.label.CalcSize(new GUIContent(strSettings)).x; GUI.Label(rectLabelSettings, strSettings, styleLabelMenu); } Rect rectBtnModify = new Rect(rectLabelSettings.x + rectLabelSettings.width + margin, rectLabelSettings.y, 60f, rectBtnOptions.height); if(GUI.Button(rectBtnModify, "Modify", EditorStyles.toolbarButton)) { EditorWindow windowSettings = ScriptableObject.CreateInstance<AMSettings>(); windowSettings.ShowUtility(); } if(rectBtnModify.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) mouseOverElement = (int)ElementType.Button; #endregion #region zoom slider if(trackCount <= 0) GUI.enabled = false; // disable slider if there are no tracks // adjust zoom slider width float width_zoom_slider_dynamic = Mathf.Clamp(position.width - (rectBtnModify.x + rectBtnModify.width) - margin - 25f, 0f, 250f); Rect rectZoomSlider = new Rect(position.width - 25f - width_zoom_slider_dynamic + 5f, rectBtnModify.y, width_zoom_slider_dynamic - 5f, 20f); if(dragType != (int)DragType.CursorZoom) aData.zoom = GUI.HorizontalSlider(rectZoomSlider, aData.zoom, 1f, 0f); else GUI.HorizontalSlider(rectZoomSlider, aData.zoom, 1f, 0f); if(rectZoomSlider.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Other; } GUI.enabled = !isPlaying; bool birdseye = (current_width_frame <= width_frame_birdseye_min ? true : false); // show or hide zoom texture if(position.width > 788 || (compact)) { GUI.DrawTexture(new Rect(position.width - 25f, 0f, 20f, 20f), getSkinTextureStyleState("zoom").background); } #endregion #endregion #region control bar #region auto-key button GUIStyle styleBtnAutoKey = new GUIStyle(GUI.skin.button); styleBtnAutoKey.clipping = TextClipping.Overflow; if(aData.autoKey) { styleBtnAutoKey.normal.background = GUI.skin.button.active.background; styleBtnAutoKey.normal.textColor = Color.red; styleBtnAutoKey.hover.background = GUI.skin.button.active.background; styleBtnAutoKey.hover.textColor = Color.red; } Rect rectBtnAutoKey = new Rect(margin, height_menu_bar + margin, 40f, 15f); if(GUI.Button(rectBtnAutoKey, new GUIContent("Auto", "Auto-Key"), styleBtnAutoKey)) aData.autoKey = !aData.autoKey; if(rectBtnAutoKey.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) mouseOverElement = (int)ElementType.Button; #endregion if(trackCount <= 0 || aData.getCurrentTake().selectedTrack == -1) GUI.enabled = false; // disable key controls if there are no tracks #region select previous key Rect rectBtnPrevKey = new Rect(rectBtnAutoKey.x + rectBtnAutoKey.width + margin, rectBtnAutoKey.y, 30f, 15f); if(GUI.Button(rectBtnPrevKey, new GUIContent((getSkinTextureStyleState("prev_key").background), "Prev. Key"), GUI.skin.GetStyle("ButtonImage"))) { timelineSelectPrevKey(); } if(rectBtnPrevKey.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) mouseOverElement = (int)ElementType.Button; #endregion # region insert key Rect rectBtnInsertKey = new Rect(rectBtnPrevKey.x + rectBtnPrevKey.width + margin, rectBtnPrevKey.y, 23f, 15f); if(GUI.Button(rectBtnInsertKey, new GUIContent("K", "Insert Key"))) { addKeyToSelectedFrame(); } if(rectBtnInsertKey.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) mouseOverElement = (int)ElementType.Button; #endregion #region select next key Rect rectBtnNextKey = new Rect(rectBtnInsertKey.x + rectBtnInsertKey.width + margin, rectBtnInsertKey.y, 30f, 15f); if(GUI.Button(rectBtnNextKey, new GUIContent((getSkinTextureStyleState("next_key").background), "Next Key"), GUI.skin.GetStyle("ButtonImage"))) { timelineSelectNextKey(); } if(rectBtnNextKey.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) mouseOverElement = (int)ElementType.Button; #endregion GUI.enabled = !isPlaying; #endregion #region playback controls Rect rectAreaPlaybackControls = new Rect(0f, position.height - height_indicator_footer, width_track + width_playback_controls, height_playback_controls); GUI.BeginGroup(rectAreaPlaybackControls); #region new track button Rect rectNewTrack = new Rect(5f, height_indicator_footer / 2f - 15f / 2f, 15f, 15f); Rect rectBtnNewTrack = new Rect(rectNewTrack.x, 0f, rectNewTrack.width, height_indicator_footer); if(GUI.Button(rectBtnNewTrack, new GUIContent("", "New Track"), "label")) { if(objects_window.Count > 0) objects_window = new List<GameObject>(); if(menu.GetItemCount() <= 0) buildAddTrackMenu(); menu.ShowAsContext(); } GUI.DrawTexture(rectNewTrack, (rectBtnNewTrack.Contains(e.mousePosition) ? tex_icon_track_hover : tex_icon_track)); if(rectBtnNewTrack.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Button; } #endregion #region new group button Rect rectNewGroup = new Rect(rectNewTrack.x + rectNewTrack.width + 5f, height_indicator_footer / 2f - 15f / 2f, 15f, 15f); Rect rectBtnNewGroup = new Rect(rectNewGroup.x, 0f, rectNewGroup.width, height_indicator_footer); if(GUI.Button(rectBtnNewGroup, new GUIContent("", "New Group"), "label")) { Undo.RecordObject(aData.getCurrentTake(), "New Group"); cancelTextEditting(); aData.getCurrentTake().addGroup(); EditorUtility.SetDirty(aData.getCurrentTake()); setScrollViewValue(maxScrollView()); } GUI.DrawTexture(rectNewGroup, (rectBtnNewGroup.Contains(e.mousePosition) ? tex_icon_group_hover : tex_icon_group_closed)); if(rectBtnNewGroup.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Button; } #endregion #region delete track button Rect rectDeleteElement = new Rect(rectNewGroup.x + rectNewGroup.width + 5f + 1f, height_indicator_footer / 2f - 11f / 2f, 11f, 11f); Rect rectBtnDeleteElement = new Rect(rectDeleteElement.x, 0f, rectDeleteElement.width, height_indicator_footer); if(aData.getCurrentTake().selectedGroup >= 0) GUI.enabled = false; if(aData.getCurrentTake().selectedGroup >= 0 && (trackCount <= 0 || (aData.getCurrentTake().contextSelectionTracks != null && aData.getCurrentTake().contextSelectionTracks.Count <= 0))) GUI.enabled = false; else GUI.enabled = !isPlaying; if(!GUI.enabled) GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.25f); GUIContent gcDeleteButton; string strTitleDeleteTrack = (aData.getCurrentTake().contextSelectionTracks != null && aData.getCurrentTake().contextSelectionTracks.Count > 1 ? "Tracks" : "Track"); if(!GUI.enabled) gcDeleteButton = new GUIContent(""); else gcDeleteButton = new GUIContent("", "Delete " + (aData.getCurrentTake().contextSelectionTracks != null && aData.getCurrentTake().contextSelectionTracks.Count > 0 ? strTitleDeleteTrack : "Group")); if(GUI.Button(rectBtnDeleteElement, gcDeleteButton, "label")) { cancelTextEditting(); if(aData.getCurrentTake().contextSelectionTracks.Count > 0) { string strMsgDeleteTrack = (aData.getCurrentTake().contextSelectionTracks.Count > 1 ? "multiple tracks" : "track '" + aData.getCurrentTake().getSelectedTrack().name + "'"); if((EditorUtility.DisplayDialog("Delete " + strTitleDeleteTrack, "Are you sure you want to delete " + strMsgDeleteTrack + "?", "Delete", "Cancel"))) { isRenamingTrack = -1; AMTake curTake = aData.getCurrentTake(); Undo.RegisterCompleteObjectUndo(curTake, "Delete Track"); List<MonoBehaviour> items = new List<MonoBehaviour>(); foreach(int track_id in curTake.contextSelectionTracks) { curTake.deleteTrack(track_id, true, ref items); } foreach(MonoBehaviour item in items) Undo.DestroyObjectImmediate(item); curTake.contextSelectionTracks = new List<int>(); // deselect track curTake.selectedTrack = -1; // deselect group curTake.selectedGroup = 0; // save data EditorUtility.SetDirty(curTake); AMCodeView.refresh(); } } else { bool delete = true; bool deleteContents = false; AMTake take = aData.getCurrentTake(); AMGroup grp = take.getGroup(take.selectedGroup); List<MonoBehaviour> items = null; if(grp.elements.Count > 0) { int choice = EditorUtility.DisplayDialogComplex("Delete Contents?", "'" + grp.group_name + "' contains contents that can be deleted with the group.", "Delete Contents", "Keep Contents", "Cancel"); if(choice == 2) delete = false; else if(choice == 0) deleteContents = true; if(delete) { if(deleteContents) { Undo.RegisterCompleteObjectUndo(take, "Delete Group"); items = new List<MonoBehaviour>(); take.deleteSelectedGroup(true, ref items); foreach(MonoBehaviour item in items) Undo.DestroyObjectImmediate(item); } else { Undo.RecordObject(take, "Delete Group"); take.deleteSelectedGroup(false, ref items); } EditorUtility.SetDirty(take); AMCodeView.refresh(); } } else { //no tracks inside group Undo.RecordObject(take, "Delete Group"); aData.getCurrentTake().deleteSelectedGroup(false, ref items); } } } GUI.DrawTexture(rectDeleteElement, (getSkinTextureStyleState((GUI.enabled && rectBtnDeleteElement.Contains(e.mousePosition) ? "delete_hover" : "delete")).background)); if(rectBtnDeleteElement.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Button; } if(GUI.color.a < 1f) GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 1f); GUI.enabled = !isPlaying; #endregion #region resize track Rect rectResizeTrack = new Rect(width_track - 5f - 10f, height_indicator_footer / 2f - 10f / 2f - 4f, 15f, 15f); GUI.Button(rectResizeTrack, "", GUI.skin.GetStyle("ResizeTrackThumb")); if(rectResizeTrack.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.ResizeTrack; } if(GUI.enabled) EditorGUIUtility.AddCursorRect(rectResizeTrack, MouseCursor.ResizeHorizontal); GUI.enabled = (aData.getCurrentTake().rootGroup != null && aData.getCurrentTake().rootGroup.elements.Count > 0 ? !isPlaying : false); #endregion #region select first frame button Rect rectBtnSkipBack = new Rect(width_track + margin, margin, 32f, height_playback_controls - margin * 2); if(GUI.Button(rectBtnSkipBack, getSkinTextureStyleState("nav_skip_back").background, GUI.skin.GetStyle("ButtonImage"))) timelineSelectFrame(aData.getCurrentTake().selectedTrack, 1); if(rectBtnSkipBack.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Button; } #endregion #region toggle play button // change label if already playing Texture playToggleTexture; if(isPlaying) playToggleTexture = getSkinTextureStyleState("nav_stop").background; else playToggleTexture = getSkinTextureStyleState("nav_play").background; GUI.enabled = (aData.getCurrentTake().rootGroup != null && aData.getCurrentTake().rootGroup.elements.Count > 0 ? true : false); Rect rectBtnTogglePlay = new Rect(rectBtnSkipBack.x + rectBtnSkipBack.width + margin, rectBtnSkipBack.y, rectBtnSkipBack.width, rectBtnSkipBack.height); if(GUI.Button(rectBtnTogglePlay, playToggleTexture, GUI.skin.GetStyle("ButtonImage"))) { if(isChangingTimeControl) isChangingTimeControl = false; if(isChangingFrameControl) isChangingFrameControl = false; // cancel renaming cancelTextEditting(); // toggle play playerTogglePlay(); } if(rectBtnTogglePlay.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Button; } #endregion #region select last frame button GUI.enabled = (aData.getCurrentTake().rootGroup != null && aData.getCurrentTake().rootGroup.elements.Count > 0 ? !isPlaying : false); Rect rectSkipForward = new Rect(rectBtnTogglePlay.x + rectBtnTogglePlay.width + margin, rectBtnTogglePlay.y, rectBtnTogglePlay.width, rectBtnTogglePlay.height); if(GUI.Button(rectSkipForward, getSkinTextureStyleState("nav_skip_forward").background, GUI.skin.GetStyle("ButtonImage"))) timelineSelectFrame(aData.getCurrentTake().selectedTrack, aData.getCurrentTake().numFrames); if(rectSkipForward.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Button; } #endregion #region playback speed popup Rect rectPopupPlaybackSpeed = new Rect(rectSkipForward.x + rectSkipForward.width + margin, height_indicator_footer / 2f - 15f / 2f, width_playback_speed, rectBtnTogglePlay.height); aData.takes[aData.currentTake].playbackSpeedIndex = EditorGUI.Popup(rectPopupPlaybackSpeed, aData.takes[aData.currentTake].playbackSpeedIndex, playbackSpeed); #endregion #region scrub controls GUIStyle styleScrubControl = new GUIStyle(GUI.skin.label); string stringTime = frameToTime(aData.getCurrentTake().selectedFrame, (float)aData.getCurrentTake().frameRate).ToString("N2") + " s"; string stringFrame = aData.getCurrentTake().selectedFrame.ToString() + " fr"; int timeFontSize = findWidthFontSize(width_scrub_control, styleScrubControl, new GUIContent(stringTime), 8, 14); int frameFontSize = findWidthFontSize(width_scrub_control, styleScrubControl, new GUIContent(stringFrame), 8, 14); styleScrubControl.fontSize = (timeFontSize <= frameFontSize ? timeFontSize : frameFontSize); #region frame control Rect rectFrameControl = new Rect(rectPopupPlaybackSpeed.x + rectPopupPlaybackSpeed.width + margin, 1f, width_scrub_control, height_indicator_footer); // frame control button if(!isChangingFrameControl) { // set time control font size if(GUI.Button(rectFrameControl, stringFrame, styleScrubControl)) { if(dragType != (int)DragType.FrameScrub) { if(isChangingTimeControl) isChangingTimeControl = false; cancelTextEditting(); isChangingFrameControl = true; } } // scrubbing cursor if(!isPlaying && aData.getCurrentTake().rootGroup != null && aData.getCurrentTake().rootGroup.elements.Count > 0) EditorGUIUtility.AddCursorRect(rectFrameControl, MouseCursor.SlideArrow); // check for drag if(rectFrameControl.Contains(e.mousePosition) && aData.getCurrentTake().rootGroup != null && aData.getCurrentTake().rootGroup.elements.Count > 0) { mouseOverElement = (int)ElementType.FrameScrub; } } else { // changing frame control selectFrame((int)Mathf.Clamp(EditorGUI.FloatField(new Rect(rectFrameControl.x, rectFrameControl.y + 2f, rectFrameControl.width, rectFrameControl.height), aData.getCurrentTake().selectedFrame, GUI.skin.textField/*,styleButtonTimeControlEdit*/), 1, aData.getCurrentTake().numFrames)); if(rectFrameControl.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Other; } } #endregion #region time control Rect rectTimeControl = new Rect(rectFrameControl.x + rectFrameControl.width + margin, rectFrameControl.y, rectFrameControl.width, rectFrameControl.height); if(!isChangingTimeControl) { // set time control font size if(GUI.Button(rectTimeControl, stringTime, styleScrubControl)) { if(dragType != (int)DragType.TimeScrub) { if(isChangingFrameControl) isChangingFrameControl = false; cancelTextEditting(); isChangingTimeControl = true; } } // scrubbing cursor if(!isPlaying && aData.getCurrentTake().rootGroup != null && aData.getCurrentTake().rootGroup.elements.Count > 0) EditorGUIUtility.AddCursorRect(rectTimeControl, MouseCursor.SlideArrow); // check for drag if(rectTimeControl.Contains(e.mousePosition) && aData.getCurrentTake().rootGroup != null && aData.getCurrentTake().rootGroup.elements.Count > 0) { mouseOverElement = (int)ElementType.TimeScrub; } } else { // changing time control selectFrame(Mathf.Clamp(timeToFrame(EditorGUI.FloatField(new Rect(rectTimeControl.x, rectTimeControl.y + 2f, rectTimeControl.width, rectTimeControl.height), frameToTime(aData.getCurrentTake().selectedFrame, (float)aData.getCurrentTake().frameRate), GUI.skin.textField/*,styleButtonTimeControlEdit*/), (float)aData.getCurrentTake().frameRate), 1, aData.getCurrentTake().numFrames)); if(rectTimeControl.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Other; } } GUI.enabled = !isPlaying; #endregion #endregion GUI.EndGroup(); Rect rectFooter = new Rect(rectAreaPlaybackControls.x, rectAreaPlaybackControls.y, position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) - 5f, rectAreaPlaybackControls.height); if(rectFooter.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Other; } #endregion #region horizontal scrollbar // check if mouse is over inspector and scroll if dragging if(globalMousePosition.y >= (height_control_bar + height_menu_bar + 2f)) { difference = 0; // drag right, over inspector if(globalMousePosition.x >= position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) - 5f) { difference = Mathf.CeilToInt(globalMousePosition.x - (position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) - 5f)); tickerSpeed = Mathf.Clamp(50 - Mathf.CeilToInt(difference / 1.5f), 1, 50); if(!aData.isInspectorOpen) tickerSpeed /= 10; // if mouse over inspector, set mouseOverElement to Other mouseOverElement = (int)ElementType.Other; if(dragType == (int)DragType.MoveSelection || dragType == (int)DragType.ContextSelection || dragType == (int)DragType.ResizeAction) { if(ticker == 0) { aData.getCurrentTake().startFrame = Mathf.Clamp(++aData.getCurrentTake().startFrame, 1, aData.getCurrentTake().numFrames); mouseXOverFrame = Mathf.Clamp((int)aData.getCurrentTake().startFrame + (int)numFramesToRender, 1, aData.getCurrentTake().numFrames); } else { mouseXOverFrame = Mathf.Clamp((int)aData.getCurrentTake().startFrame + (int)numFramesToRender, 1, aData.getCurrentTake().numFrames); } } // drag left, over tracks } else if(globalMousePosition.x <= width_track - 5f) { difference = Mathf.CeilToInt((width_track - 5f) - globalMousePosition.x); tickerSpeed = Mathf.Clamp(50 - Mathf.CeilToInt(difference / 1.5f), 1, 50); if(dragType == (int)DragType.MoveSelection || dragType == (int)DragType.ContextSelection || dragType == (int)DragType.ResizeAction) { if(ticker == 0) { aData.getCurrentTake().startFrame = Mathf.Clamp(--aData.getCurrentTake().startFrame, 1, aData.getCurrentTake().numFrames); mouseXOverFrame = Mathf.Clamp((int)aData.getCurrentTake().startFrame - 2, 1, aData.getCurrentTake().numFrames); } else { mouseXOverFrame = Mathf.Clamp((int)aData.getCurrentTake().startFrame, 1, aData.getCurrentTake().numFrames); } } } } Rect rectHScrollbar = new Rect(width_track + width_playback_controls, position.height - height_indicator_footer + 2f, position.width - (width_track + width_playback_controls) - (aData.isInspectorOpen ? width_inspector_open - 4f : width_inspector_closed) - 21f, height_indicator_footer - 2f); float frame_width_HScrollbar = ((rectHScrollbar.width - 44f - (aData.isInspectorOpen ? 4f : 0f)) / ((float)aData.getCurrentTake().numFrames - 1f)); Rect rectResizeHScrollbarLeft = new Rect(rectHScrollbar.x + 18f + frame_width_HScrollbar * (aData.getCurrentTake().startFrame - 1f), rectHScrollbar.y + 2f, 15f, 15f); Rect rectResizeHScrollbarRight = new Rect(rectHScrollbar.x + 18f + frame_width_HScrollbar * (aData.getCurrentTake().endFrame - 1f) - 3f, rectHScrollbar.y + 2f, 15f, 15f); Rect rectHScrollbarThumb = new Rect(rectResizeHScrollbarLeft.x, rectResizeHScrollbarLeft.y - 2f, rectResizeHScrollbarRight.x - rectResizeHScrollbarLeft.x + rectResizeHScrollbarRight.width, rectResizeHScrollbarLeft.height); if(!aData.isInspectorOpen) rectHScrollbar.width += 4f; // if number of frames fit on screen, disable horizontal scrollbar and set startframe to 1 if(aData.getCurrentTake().numFrames < numFramesToRender) { GUI.HorizontalScrollbar(rectHScrollbar, 1f, 1f, 1f, 1f); aData.getCurrentTake().startFrame = 1; } else { bool hideResizeThumbs = false; if(rectHScrollbarThumb.width < rectResizeHScrollbarLeft.width * 2) { hideResizeThumbs = true; rectResizeHScrollbarLeft = new Rect(rectHScrollbarThumb.x - 4f, rectResizeHScrollbarLeft.y, rectHScrollbarThumb.width / 2f + 4f, rectResizeHScrollbarLeft.height); rectResizeHScrollbarRight = new Rect(rectHScrollbarThumb.x + rectHScrollbarThumb.width - rectHScrollbarThumb.width / 2f, rectResizeHScrollbarRight.y, rectResizeHScrollbarLeft.width, rectResizeHScrollbarRight.height); } mouseXOverHScrollbarFrame = Mathf.CeilToInt(aData.getCurrentTake().numFrames * ((e.mousePosition.x - rectHScrollbar.x - GUI.skin.horizontalScrollbarLeftButton.fixedWidth) / (rectHScrollbar.width - GUI.skin.horizontalScrollbarLeftButton.fixedWidth * 2))); if(!rectResizeHScrollbarLeft.Contains(e.mousePosition) && !rectResizeHScrollbarRight.Contains(e.mousePosition) && EditorWindow.mouseOverWindow == this && dragType != (int)DragType.ResizeHScrollbarLeft && dragType != (int)DragType.ResizeHScrollbarRight && mouseOverElement != (int)ElementType.ResizeHScrollbarLeft && mouseOverElement != (int)ElementType.ResizeHScrollbarRight) aData.getCurrentTake().startFrame = Mathf.Clamp((int)GUI.HorizontalScrollbar(rectHScrollbar, (float)aData.getCurrentTake().startFrame, (int)numFramesToRender - 1f, 1f, aData.getCurrentTake().numFrames), 1, aData.getCurrentTake().numFrames); else Mathf.Clamp(GUI.HorizontalScrollbar(rectHScrollbar, (float)aData.getCurrentTake().startFrame, (int)numFramesToRender - 1f, 1f, aData.getCurrentTake().numFrames), 1f, aData.getCurrentTake().numFrames); // scrollbar bg overlay (used to hide inconsistent thumb) GUI.Box(new Rect(rectHScrollbar.x + 18f, rectHScrollbar.y, rectHScrollbar.width - 18f * 2f, rectHScrollbar.height), "", GUI.skin.horizontalScrollbar); // scrollbar thumb overlay (used to hide inconsistent thumb) GUI.Box(rectHScrollbarThumb, "", GUI.skin.horizontalScrollbarThumb); if(!hideResizeThumbs) { if(!GUI.enabled) GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.25f); GUI.DrawTexture(rectResizeHScrollbarLeft, GUI.skin.GetStyle("ResizeTrackThumb").normal.background); GUI.DrawTexture(rectResizeHScrollbarRight, GUI.skin.GetStyle("ResizeTrackThumb").normal.background); GUI.color = Color.white; } if(GUI.enabled && !isDragging) { EditorGUIUtility.AddCursorRect(rectResizeHScrollbarLeft, MouseCursor.ResizeHorizontal); EditorGUIUtility.AddCursorRect(rectResizeHScrollbarRight, MouseCursor.ResizeHorizontal); } // show horizontal scrollbar if(rectResizeHScrollbarLeft.Contains(e.mousePosition) && customCursor == (int)CursorType.None) { mouseOverElement = (int)ElementType.ResizeHScrollbarLeft; } else if(rectResizeHScrollbarRight.Contains(e.mousePosition) && customCursor == (int)CursorType.None) { mouseOverElement = (int)ElementType.ResizeHScrollbarRight; } } aData.getCurrentTake().endFrame = aData.getCurrentTake().startFrame + (int)numFramesToRender - 1; if(rectHScrollbar.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Other; } #endregion #region inspector toggle button Rect rectPropertiesButton = new Rect(position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) - 1f, height_menu_bar + height_control_bar + 2f, width_inspector_closed, position.height); GUI.color = getSkinTextureStyleState("properties_bg").textColor; GUI.DrawTexture(rectPropertiesButton, getSkinTextureStyleState("properties_bg").background); GUI.color = Color.white; // inspector toggle button if(GUI.Button(rectPropertiesButton, "", "label")) { aData.isInspectorOpen = !aData.isInspectorOpen; } if(rectPropertiesButton.Contains(e.mousePosition) && mouseOverElement == (int)ElementType.None) { mouseOverElement = (int)ElementType.Button; } #endregion #region key numbering Rect rectKeyNumbering = new Rect(width_track, height_control_bar + height_menu_bar + 2f - 22f, position.width - width_track - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) - 20f, 20f); if(rectKeyNumbering.Contains(e.mousePosition) && (mouseOverElement == (int)ElementType.None)) { mouseOverElement = (int)ElementType.TimelineScrub; } int key_dist = 5; if(numFramesToRender >= 100) key_dist = Mathf.FloorToInt(numFramesToRender / 100) * 10; int firstMarkedKey = (int)aData.getCurrentTake().startFrame; if(firstMarkedKey % key_dist != 0 && firstMarkedKey != 1) { firstMarkedKey += key_dist - firstMarkedKey % key_dist; } float lastNumberX = -1f; for(int i = firstMarkedKey; i <= (int)aData.getCurrentTake().endFrame; i += key_dist) { float newKeyNumberX = width_track + current_width_frame * (i - (int)aData.getCurrentTake().startFrame) - 1f; string key_number; if(oData.time_numbering) key_number = frameToTime(i, (float)aData.getCurrentTake().frameRate).ToString("N2"); else key_number = i.ToString(); Rect rectKeyNumber = new Rect(newKeyNumberX, height_menu_bar, GUI.skin.label.CalcSize(new GUIContent(key_number)).x, height_control_bar); bool didCutLabel = false; if(rectKeyNumber.x + rectKeyNumber.width >= position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) - 20f) { rectKeyNumber.width = position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) - 20f - rectKeyNumber.x; didCutLabel = true; } if(!(didCutLabel && aData.getCurrentTake().endFrame == aData.getCurrentTake().numFrames)) { if(rectKeyNumber.x > lastNumberX + 3f) { GUI.Label(rectKeyNumber, key_number); lastNumberX = rectKeyNumber.x + GUI.skin.label.CalcSize(new GUIContent(key_number)).x; } } if(i == 1) i--; } #endregion #region main scrollview height_all_tracks = aData.getCurrentTake().getElementsHeight(0, height_track, height_track_foldin, height_group); float height_scrollview = position.height - (height_control_bar + height_menu_bar) - height_indicator_footer; // check if mouse is beyond tracks and dragging group element difference = 0; // drag up if(dragType == (int)DragType.GroupElement && globalMousePosition.y <= height_control_bar + height_menu_bar + 2f) { difference = Mathf.CeilToInt((height_control_bar + height_menu_bar + 2f) - globalMousePosition.y); scrollAmountVertical = -difference; // set scroll amount // drag down } else if(dragType == (int)DragType.GroupElement && globalMousePosition.y >= position.height - height_playback_controls) { difference = Mathf.CeilToInt(globalMousePosition.y - (position.height - height_playback_controls)); scrollAmountVertical = difference; // set scroll amount } else { scrollAmountVertical = 0f; } // frames bg GUI.DrawTexture(new Rect(0f, height_control_bar + height_menu_bar + 2f, position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) - 5f, position.height - height_control_bar - height_menu_bar - height_indicator_footer), GUI.skin.GetStyle("GroupElementBG").onNormal.background); // tracks bg GUI.Box(new Rect(0f, height_control_bar + height_menu_bar + 2f, width_track, position.height - height_control_bar - height_menu_bar - height_indicator_footer), "", GUI.skin.GetStyle("GroupElementBG")); Rect rectScrollView = new Rect(0f, height_control_bar + height_menu_bar + 2f, position.width - (aData.isInspectorOpen ? width_inspector_open/*+3f*/ : width_inspector_closed), height_scrollview); Rect rectView = new Rect(0f, 0f, rectScrollView.width - 20f, (height_all_tracks > rectScrollView.height ? height_all_tracks : rectScrollView.height)); scrollViewValue = GUI.BeginScrollView(rectScrollView, scrollViewValue, rectView, false, true); scrollViewValue.y = Mathf.Clamp(scrollViewValue.y, 0f, height_all_tracks - height_scrollview); Vector2 scrollViewBounds = new Vector2(scrollViewValue.y, scrollViewValue.y + height_scrollview); // min and max y displayed onscreen bool isAnyTrackFoldedOut = false; GUILayout.BeginHorizontal(GUILayout.Height(height_all_tracks)); GUILayout.BeginVertical(GUILayout.Width(width_track)); float track_y = 0f; // the next track's y position // tracks vertical start for(int i = 0; i < aData.getCurrentTake().rootGroup.elements.Count; i++) { if(track_y > scrollViewBounds.y) break; // if start y is beyond max y int id = aData.getCurrentTake().rootGroup.elements[i]; float height_group_elements = 0f; showGroupElement(id, 0, ref track_y, ref isAnyTrackFoldedOut, ref height_group_elements, e, scrollViewBounds); } // draw element position indicator if(dragType == (int)DragType.GroupElement) { if(mouseOverElement != (int)ElementType.Group && mouseOverElement != (int)ElementType.GroupOutside && mouseOverElement != (int)ElementType.Track) { float element_position_y; if(e.mousePosition.y < (height_menu_bar + height_control_bar)) element_position_y = 2f; else element_position_y = track_y; GUI.DrawTexture(new Rect(0f, element_position_y - height_element_position, width_track, height_element_position), tex_element_position); } } GUILayout.EndVertical(); GUILayout.BeginVertical(); // frames vertical GUILayout.BeginHorizontal(GUILayout.Height(height_track)); mouseXOverFrame = (int)aData.getCurrentTake().startFrame + Mathf.CeilToInt((e.mousePosition.x - width_track) / current_width_frame) - 1; if(dragType == (int)DragType.CursorHand && justStartedHandGrab) { startScrubFrame = mouseXOverFrame; justStartedHandGrab = false; } track_y = 0f; // reset track y showFramesForGroup(0, ref track_y, e, birdseye, scrollViewBounds); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndScrollView(); #endregion #region inspector Texture inspectorArrow; if(aData.isInspectorOpen) { Rect rectInspector = new Rect(position.width - width_inspector_open - 4f + width_inspector_closed, height_control_bar + height_menu_bar + 2f, width_inspector_open, position.height - height_menu_bar - height_control_bar); GUI.BeginGroup(rectInspector); // inspector vertical GUI.enabled = true; GUI.enabled = !isPlaying; // backup editor styles GUIStyle styleEditorTextField = new GUIStyle(EditorStyles.textField); GUIStyle styleEditorLabel = new GUIStyle(EditorStyles.label); // modify editor styles EditorStyles.textField.normal = GUI.skin.textField.normal; EditorStyles.textField.focused = GUI.skin.textField.focused; EditorStyles.label.normal = GUI.skin.label.normal; showInspectorPropertiesFor(rectInspector, aData.getCurrentTake().selectedTrack, aData.getCurrentTake().selectedFrame, e); // reset editor styles EditorStyles.textField.normal = styleEditorTextField.normal; EditorStyles.textField.focused = styleEditorTextField.focused; EditorStyles.label.normal = styleEditorLabel.normal; inspectorArrow = texRightArrow; GUI.EndGroup(); } else { GUI.enabled = true; GUI.enabled = !isPlaying; inspectorArrow = texLeftArrow; } GUI.DrawTexture(new Rect(position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) + 4f, 60f, 22f, 19f), inspectorArrow); GUI.DrawTexture(new Rect(position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed) - 8f, 73f, 48f, 48f), texProperties); #endregion #region indicator if((oData.showFramesForCollapsedTracks || isAnyTrackFoldedOut) && (trackCount > 0)) drawIndicator(aData.getCurrentTake().selectedFrame); #endregion #region horizontal scrollbar tooltip string strHScrollbarLeftTooltip = (oData.time_numbering ? frameToTime((int)aData.getCurrentTake().startFrame, (float)aData.getCurrentTake().frameRate).ToString("N2") : aData.getCurrentTake().startFrame.ToString()); string strHScrollbarRightTooltip = (oData.time_numbering ? frameToTime((int)aData.getCurrentTake().endFrame, (float)aData.getCurrentTake().frameRate).ToString("N2") : aData.getCurrentTake().endFrame.ToString()); GUIStyle styleLabelCenter = new GUIStyle(GUI.skin.label); styleLabelCenter.alignment = TextAnchor.MiddleCenter; Vector2 _label_size; if(customCursor == (int)CursorType.None && ((mouseOverElement == (int)ElementType.ResizeHScrollbarLeft && !isDragging) || dragType == (int)DragType.ResizeHScrollbarLeft) && (dragType != (int)DragType.ResizeHScrollbarRight)) { _label_size = GUI.skin.button.CalcSize(new GUIContent(strHScrollbarLeftTooltip)); _label_size.x += 2f; GUI.Label(new Rect(rectResizeHScrollbarLeft.x + rectResizeHScrollbarLeft.width / 2f - _label_size.x / 2f, rectResizeHScrollbarLeft.y - 22f, _label_size.x, 20f), strHScrollbarLeftTooltip, GUI.skin.button); } if(customCursor == (int)CursorType.None && ((mouseOverElement == (int)ElementType.ResizeHScrollbarRight && !isDragging) || dragType == (int)DragType.ResizeHScrollbarRight) && (dragType != (int)DragType.ResizeHScrollbarLeft)) { _label_size = GUI.skin.button.CalcSize(new GUIContent(strHScrollbarRightTooltip)); _label_size.x += 2f; GUI.Label(new Rect(rectResizeHScrollbarRight.x + rectResizeHScrollbarRight.width / 2f - _label_size.x / 2f, rectResizeHScrollbarRight.y - 22f, _label_size.x, 20f), strHScrollbarRightTooltip, GUI.skin.button); } #endregion #region click window if(GUI.Button(new Rect(0f, 0f, position.width, position.height), "", "label") && dragType != (int)DragType.TimelineScrub && dragType != (int)DragType.ResizeAction) { bool didRegisterUndo = false; if(aData.getCurrentTake().contextSelectionTracks != null && aData.getCurrentTake().contextSelectionTracks.Count > 0) { Undo.RecordObject(aData.getCurrentTake(), "Deselect Tracks"); didRegisterUndo = true; aData.getCurrentTake().contextSelectionTracks = new List<int>(); } if(aData.getCurrentTake().contextSelection != null && aData.getCurrentTake().contextSelection.Count > 0) { if(!didRegisterUndo) Undo.RecordObject(aData.getCurrentTake(), "Deselect Frames"); didRegisterUndo = true; aData.getCurrentTake().contextSelection = new List<int>(); } if(aData.getCurrentTake().ghostSelection != null && aData.getCurrentTake().ghostSelection.Count > 0) { aData.getCurrentTake().ghostSelection = new List<int>(); } if(objects_window.Count > 0) objects_window = new List<GameObject>(); if(isRenamingGroup < 0) isRenamingGroup = 0; if(isRenamingTake) { aData.makeTakeNameUnique(aData.getCurrentTake()); isRenamingTake = false; } if(isRenamingTrack != -1) isRenamingTrack = -1; if(isChangingTimeControl) isChangingTimeControl = false; if(isChangingFrameControl) isChangingFrameControl = false; // if clicked on inspector, do nothing if(e.mousePosition.y > (float)height_menu_bar + (float)height_control_bar && e.mousePosition.x > position.width - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed)) return; if(aData.getCurrentTake().selectedGroup != 0) timelineSelectGroup(0); if(aData.getCurrentTake().selectedTrack != -1) aData.getCurrentTake().selectedTrack = -1; if(objects_window.Count > 0) objects_window = new List<GameObject>(); } #endregion #region drag logic if(dragType == (int)DragType.GroupElement) { // show element near cursor Rect rectDragElement = new Rect(e.mousePosition.x + 20f, e.mousePosition.y, 90f, 20f); string dragElementName = "Unknown"; Texture dragElementIcon = null; float dragElementIconWidth = 12f; if(draggingGroupElementType == (int)ElementType.Group) { dragElementName = aData.getCurrentTake().getGroup((int)draggingGroupElement.x).group_name; dragElementIcon = tex_icon_group_closed; dragElementIconWidth = 16f; } else if(draggingGroupElementType == (int)ElementType.Track) { AMTrack dragTrack = aData.getCurrentTake().getTrack((int)draggingGroupElement.y); if(dragTrack) { dragElementName = dragTrack.name; dragElementIcon = getTrackIconTexture(dragTrack); } } GUI.DrawTexture(rectDragElement, GUI.skin.GetStyle("GroupElementActive").normal.background); dragElementName = trimString(dragElementName, 8); if(dragElementIcon) GUI.DrawTexture(new Rect(rectDragElement.x + 3f + (draggingGroupElementType == (int)ElementType.Track ? 1.45f : 0f), rectDragElement.y + rectDragElement.height / 2 - dragElementIconWidth / 2, dragElementIconWidth, dragElementIconWidth), dragElementIcon); GUI.Label(new Rect(rectDragElement.x + 15f + 4f, rectDragElement.y, rectDragElement.width - 15f - 4f, rectDragElement.height), dragElementName); } mouseAboveGroupElements = e.mousePosition.y < (height_menu_bar + height_control_bar); if(aData.getCurrentTake().rootGroup == null || aData.getCurrentTake().rootGroup.elements.Count <= 0) { if(aData.isInspectorOpen) aData.isInspectorOpen = false; float width_helpbox = position.width - width_inspector_closed - 28f - width_track; EditorGUI.HelpBox(new Rect(width_track + 5f, height_menu_bar + height_control_bar + 7f, width_helpbox, 50f), "Click the track icon below or drag a GameObject here to add a new track.", MessageType.Info); //GUI.DrawTexture(new Rect(width_track+75f,height_menu_bar+height_control_bar+19f-(width_helpbox<=355.5f ? 6f: 0f),15f,15f),tex_icon_track); } #endregion #region quick add GUIStyle styleObjectField = new GUIStyle(EditorStyles.objectField); GUIStyle styleObjectFieldThumb = new GUIStyle(EditorStyles.objectFieldThumb); EditorStyles.objectField.normal.textColor = new Color(0f, 0f, 0f, 0f); EditorStyles.objectField.contentOffset = new Vector2(width_track * -1 - 300f, 0f); EditorStyles.objectField.normal.background = null; EditorStyles.objectField.onNormal.background = null; GameObject tempGO = null; tempGO = (GameObject)EditorGUI.ObjectField(new Rect(width_track, height_menu_bar + height_control_bar + 2f, position.width - 5f - 15f - width_track - (aData.isInspectorOpen ? width_inspector_open : width_inspector_closed), position.height - height_indicator_footer - height_menu_bar - height_control_bar), "", tempGO, typeof(GameObject), true); if(tempGO != null) { objects_window = new List<GameObject>(); if(Selection.gameObjects.Length <= 0) objects_window.Add(tempGO); else objects_window.AddRange(Selection.gameObjects); buildAddTrackMenu_Drag(); menu_drag.ShowAsContext(); } EditorStyles.objectField.contentOffset = styleObjectField.contentOffset; EditorStyles.objectField.normal = styleObjectField.normal; EditorStyles.objectField.onNormal = styleObjectField.onNormal; EditorStyles.objectFieldThumb.normal = styleObjectFieldThumb.normal; #endregion #region tooltip if(!oData.disableTimelineActions && !oData.disableTimelineActionsTooltip && dragType == (int)DragType.None && showTooltip && tooltip != "") { Vector2 tooltipSize = GUI.skin.label.CalcSize(new GUIContent(tooltip)); tooltipSize.x += GUI.skin.button.padding.left + GUI.skin.button.padding.right; tooltipSize.y += GUI.skin.button.padding.top + GUI.skin.button.padding.bottom; Rect rectTooltip = new Rect(e.mousePosition.x - tooltipSize.x / 2f, (e.mousePosition.y + 30f + tooltipSize.y <= position.height - height_playback_controls ? e.mousePosition.y + 30f : e.mousePosition.y - 12f - tooltipSize.y), tooltipSize.x, tooltipSize.y); GUI.Box(rectTooltip, tooltip, GUI.skin.button); } #endregion #region custom cursor if(customCursor != (int)CursorType.None) { if(customCursor == (int)CursorType.Zoom) { if(!tex_cursor_zoom) tex_cursor_zoom = tex_cursor_zoomin; if(tex_cursor_zoom == tex_cursor_zoomin && aData.zoom <= 0f) tex_cursor_zoom = tex_cursor_zoom_blank; else if(tex_cursor_zoom == tex_cursor_zoomout && aData.zoom >= 1f) tex_cursor_zoom = tex_cursor_zoom_blank; GUI.DrawTexture(new Rect(e.mousePosition.x - 6f, e.mousePosition.y - 5f, 16f, 16f), tex_cursor_zoom); } else if(customCursor == (int)CursorType.Hand) { GUI.DrawTexture(new Rect(e.mousePosition.x - 8f, e.mousePosition.y - 7f, 16f, 16f), (tex_cursor_grab)); } } #endregion if(e.alt && !isDragging) startZoomXOverFrame = mouseXOverFrame; e.Use(); if(doRefresh) { ClearKeysBuffer(); contextSelectionTracksBuffer.Clear(); cachedContextSelection.Clear(); GameObject go = _aData.gameObject; _aData.isAnimatorOpen = false; _aData = null; Selection.activeGameObject = go; } }
void OnUndoRedo() { if(isPlaying) isPlaying = false; if(_aData != null) _aData = _aData.gameObject.GetComponent<AnimatorData>(); Repaint(); // recheck for component /*GameObject go = GameObject.Find("AnimatorData"); if(go) { aData = (AnimatorData)go.GetComponent("AnimatorData"); } else { aData = null; }*/ // repaint //this.Repaint(); //repaintBuffer = repaintRefreshRate; // reload AnimatorData for other windows ReloadOtherWindows(); }
public static bool showEasePicker(AMTrack track, AMKey key, AnimatorData aData, float x = -1f, float y = -1f, float width = -1f) { bool didUpdate = false; if(x >= 0f && y >= 0f && width >= 0f) { width--; float height = 22f; Rect rectLabel = new Rect(x, y - 1f, 40f, height); GUI.Label(rectLabel, "Ease"); Rect rectPopup = new Rect(rectLabel.x + rectLabel.width + 2f, y + 3f, width - rectLabel.width - width_button_delete - 3f, height); int nease = EditorGUI.Popup(rectPopup, key.easeType, easeTypeNames); if(key.easeType != nease) { recordUndoTrackAndKeys(track, false, "Change Ease"); key.setEaseType(nease); // update cache when modifying varaibles track.updateCache(); AMCodeView.refresh(); // preview new position aData.getCurrentTake().previewFrame(aData.getCurrentTake().selectedFrame); // save data EditorUtility.SetDirty(track); setDirtyKeys(track); // refresh component didUpdate = true; // refresh values AMEasePicker.refreshValues(); } Rect rectButton = new Rect(width - width_button_delete + 1f, y, width_button_delete, width_button_delete); if(GUI.Button(rectButton, getSkinTextureStyleState("popup").background, GUI.skin.GetStyle("ButtonImage"))) { AMEasePicker.setValues(/*aData,*/key, track); EditorWindow.GetWindow(typeof(AMEasePicker)); } //display specific variable for certain tweens //TODO: only show this for specific tweens if(!key.hasCustomEase()) { y += rectButton.height + 4; Rect rectAmp = new Rect(x, y, 200f, height); key.amplitude = EditorGUI.FloatField(rectAmp, "Amplitude", key.amplitude); y += rectAmp.height + 4; Rect rectPer = new Rect(x, y, 200f, height); key.period = EditorGUI.FloatField(rectPer, "Period", key.period); } } else { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.Space(1f); GUILayout.Label("Ease"); GUILayout.EndVertical(); GUILayout.BeginVertical(); GUILayout.Space(3f); int nease = EditorGUILayout.Popup(key.easeType, easeTypeNames); if(key.easeType != nease) { recordUndoTrackAndKeys(track, false, "Change Ease"); key.setEaseType(nease); // update cache when modifying varaibles track.updateCache(); AMCodeView.refresh(); // preview new position aData.getCurrentTake().previewFrame(aData.getCurrentTake().selectedFrame); // save data EditorUtility.SetDirty(track); setDirtyKeys(track); // refresh component didUpdate = true; // refresh values AMEasePicker.refreshValues(); } GUILayout.EndVertical(); if(GUILayout.Button(getSkinTextureStyleState("popup").background, GUI.skin.GetStyle("ButtonImage"), GUILayout.Width(width_button_delete), GUILayout.Height(width_button_delete))) { AMEasePicker.setValues(/*aData,*/key, track); EditorWindow.GetWindow(typeof(AMEasePicker)); } GUILayout.Space(1f); GUILayout.EndHorizontal(); //display specific variable for certain tweens //TODO: only show this for specific tweens if(!key.hasCustomEase()) { key.amplitude = EditorGUILayout.FloatField("Amplitude", key.amplitude); key.period = EditorGUILayout.FloatField("Period", key.period); } } return didUpdate; }
void OnLauncherAnimComplete(AnimatorData animDat, AMTake take) { mTarget = null; InvokeRepeating("DoActiveCheck", launcherFireDelay, activateCheckDelay); }
public void reloadAnimatorData() { aData = null; loadAnimatorData(); AMTake take = aData.getCurrentTake(); // update references for track and key bool shouldClose = true; foreach(AMTrack _track in take.trackValues) { if(track == _track) { track = _track; foreach(AMKey _key in track.keys) { if(key == _key) { key = _key; shouldClose = false; } } } } if(shouldClose) this.Close(); }
public bool IsDataMatch(AnimatorData aData) { return aData == mData; }
void AnimCompleted(AnimatorData dat, AMTake _take) { if(repeat && !mStopped) Invoke("DoPlay", repeatDelay); }
void Awake() { if(animDat == null) animDat = GetComponent<AnimatorData>(); animDat.takeCompleteCallback += AnimCompleted; }
void OnAnimationEnd(AnimatorData dat, AMTake take) { StartGame(); }
void loadAnimatorData() { if(AMTimeline.window != null) { aData = AMTimeline.window.aData; } }
void Awake() { mAnimDat = GetComponent<AnimatorData>(); }
void OnShellAnimDone(AnimatorData anim, AMTake take) { if(take.name == "close") { shellAnimDat.Play("normal"); Invoke(openFunc, openDelay); } else if(take.name == "open") { mIsOpen = true; stats.isInvul = false; mLastShotTime = Time.time; mCurShotCount = 0; InvokeRepeating(orientFunc, 0, orientAcquireDelay); } }
void loadAnimatorData() { GameObject go = GameObject.Find ("AnimatorData"); if(go) { aData = (AnimatorData) go.GetComponent ("AnimatorData"); if(aData) { if(aData.playOnStart != null) playOnStartIndex = aData.getTakeIndex(aData.playOnStart) + 1; exportTakeIndex = aData.getTakeIndex(aData.getCurrentTake()); } } }