private void _GUI_AddNewCurve() { EditorWindow uaw = (EditorWindow)EUtil.GetUnityAnimationWindow(); object uawstate = EUtil.GetUnityAnimationWindowState(uaw); m_CurClip = RCall.GetField("UnityEditorInternal.AnimationWindowState", "m_ActiveAnimationClip", uawstate) as AnimationClip; if (m_CurClip == null) { EditorGUILayout.LabelField("Need an animation clip first..."); return; } m_NewPath = EditorGUILayout.TextField("Path:", m_NewPath); m_NewProperty = EditorGUILayout.TextField("Property:", m_NewProperty); m_TypeFullName = EditorGUILayout.TextField("TypeFullName:", m_TypeFullName); m_bIsPPtrCurve = EditorGUILayout.Toggle("IsPPtrCurve:", m_bIsPPtrCurve); EditorGUILayout.Separator(); bool bOK = true; EUtil.PushGUIColor(Color.red); if (string.IsNullOrEmpty(m_NewProperty)) { bOK = false; EditorGUILayout.LabelField("Property is not specified"); } if (string.IsNullOrEmpty(m_TypeFullName) || RCall.GetTypeFromString(m_TypeFullName, true) == null) { bOK = false; EditorGUILayout.LabelField(string.Format("No type is found for name: {0}", m_TypeFullName)); } EUtil.PopGUIColor(); EUtil.PushGUIEnable(bOK); { if (EUtil.Button("Add New Curve", Color.green)) { Type tp = RCall.GetTypeFromString(m_TypeFullName); if (m_bIsPPtrCurve) { EditorCurveBinding newBinding = EditorCurveBinding.PPtrCurve(m_NewPath, tp, m_NewProperty); AnimationUtility.SetObjectReferenceCurve(m_CurClip, newBinding, new ObjectReferenceKeyframe[0]); } else { EditorCurveBinding newBinding = EditorCurveBinding.FloatCurve(m_NewPath, tp, m_NewProperty); AnimationUtility.SetEditorCurve(m_CurClip, newBinding, new AnimationCurve()); } } } EUtil.PopGUIEnable(); }
void OnGUI() { if (EditorApplication.isPlayingOrWillChangePlaymode) { return; } bool bIsCutScene = m_evtGoRoot != null; EUtil.PushGUIColor(bIsCutScene ? Color.green : Color.red); EditorGUILayout.LabelField(string.Format("AnimClip Root: {0}", (m_ClipRoot == null ? "null" : m_ClipRoot.name) )); EUtil.PopGUIColor(); Color c; String msg; if (bIsCutScene) { if (EUtil.Button("Sync AnimEvents with EventGO", Color.green)) { _MatchEventGOAndAnimEvent(); } if (EUtil.Button("Remove Animation/Animator on decendants", Color.yellow)) { _RemoveAnimCompsOnDecendants(); } if (EUtil.Button("Fix Duplicate Transform Path", Color.white)) { _FixDuplicateTransformPath(); } c = m_bShowMark4SelectedCurves ? Color.green : Color.red; msg = m_bShowMark4SelectedCurves ? "Hide Marks for Selected Curves" : "Show Marks for Selected Curves"; if (EUtil.Button(msg, c)) { m_bShowMark4SelectedCurves = !m_bShowMark4SelectedCurves; SceneView.RepaintAll(); } } else { if (EUtil.Button("New CCRoot", Color.green)) { GameObject newCCRoot = new GameObject(); newCCRoot.name = "NewCCRoot"; newCCRoot.AddComponent <CutsceneController>(); var anim = newCCRoot.AddComponent <Animation>(); anim.playAutomatically = false; Misc.ForceGetGO(EventGOS, newCCRoot); Selection.activeGameObject = newCCRoot; } c = m_bShowMark4SelectedCurves ? Color.green : Color.red; msg = m_bShowMark4SelectedCurves ? "Hide Marks for Selected Curves" : "Show Marks for Selected Curves"; if (EUtil.Button(msg, c)) { m_bShowMark4SelectedCurves = !m_bShowMark4SelectedCurves; SceneView.RepaintAll(); } } }