コード例 #1
0
        private void _GUI_EditSingleCurve()
        {
            EditorWindow uaw      = (EditorWindow)EUtil.GetUnityAnimationWindow();
            object       uawstate = EUtil.GetUnityAnimationWindowState(uaw);

            m_CurClip = RCall.GetField("UnityEditorInternal.AnimationWindowState",
                                       "m_ActiveAnimationClip", uawstate) as AnimationClip;

            IList curves = (IList)RCall.GetProp("UnityEditorInternal.AnimationWindowState", "activeCurves", uawstate);

            if (curves.Count != 1)
            {
                EditorGUILayout.LabelField(string.Format("Please select ONE curve, you have currently selected {0} curves", curves.Count));
                return;
            }

            object             oneCurve   = curves[0]; //AnimationWindowCurve
            EditorCurveBinding oneBinding = (EditorCurveBinding)RCall.GetProp("UnityEditorInternal.AnimationWindowCurve", "binding", oneCurve);

            EditorGUILayout.LabelField("Path:");
            EUtil.PushContentColor(Color.yellow);
            EditorGUILayout.SelectableLabel(oneBinding.path);
            EUtil.PopContentColor();

            EditorGUILayout.LabelField("Property:");
            EUtil.PushContentColor(Color.green);
            EditorGUILayout.SelectableLabel(oneBinding.propertyName);
            EUtil.PopContentColor();

            EditorGUILayout.LabelField("IsPPtrCurve:  " + oneBinding.isPPtrCurve.ToString());

            EditorGUILayout.Separator();

            m_NewType = EditorGUILayout.TextField("Type:", m_NewType);
            if (m_NewType.Length == 0)
            {
                m_NewType = oneBinding.type.ToString();
            }

            m_NewPath     = EditorGUILayout.TextField("New Path:", m_NewPath);
            m_NewProperty = EditorGUILayout.TextField("New Property:", m_NewProperty);

            Type newTp = RCall.GetTypeFromString(m_NewType, true);

            EUtil.PushGUIEnable(m_NewProperty.Length > 0 && newTp != null);
            if (EUtil.Button("Apply Change", Color.green))
            {
                Undo.RegisterCompleteObjectUndo(m_CurClip, "Apply Curve Change");
                _ModifyCurveBinding(oneBinding, m_NewPath, m_NewProperty, newTp);
            }
            EUtil.PopGUIEnable();
        }
コード例 #2
0
        private void _GUI_BatchAddPrefix()
        {
            EditorWindow uaw      = (EditorWindow)EUtil.GetUnityAnimationWindow();
            object       uawstate = EUtil.GetUnityAnimationWindowState(uaw);

            m_CurClip = RCall.GetField("UnityEditorInternal.AnimationWindowState",
                                       "m_ActiveAnimationClip", uawstate) as AnimationClip;

            //1. collect the TrPaths from active curves
            List <BindingInfo> bindingInfos = new List <BindingInfo>();

            IList curves = (IList)RCall.GetProp("UnityEditorInternal.AnimationWindowState", "activeCurves", uawstate);

            for (int idx = 0; idx < curves.Count; ++idx)
            {
                object             oneCurve   = curves[idx]; //AnimationWindowCurve
                EditorCurveBinding oneBinding = (EditorCurveBinding)RCall.GetProp("UnityEditorInternal.AnimationWindowCurve", "binding", oneCurve);
                bindingInfos.Add(new BindingInfo(oneBinding, oneCurve));
            }

            //2. display
            EditorGUILayout.LabelField("Selected curves:");
            m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos, false, true, GUILayout.Height(200f));
            {
                foreach (var oneInfo in bindingInfos)
                {
                    EditorCurveBinding oneBinding = oneInfo.m_Binding;
                    GUILayout.BeginHorizontal();
                    {
                        EUtil.PushContentColor(Color.yellow);
                        GUILayout.Label(oneBinding.path);
                        EUtil.PopContentColor();
                        EUtil.PushContentColor(Color.green);
                        GUILayout.Label(oneBinding.propertyName);
                        EUtil.PopContentColor();
                    }
                    GUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndScrollView();

            //3. apply prefix
            m_Prefix = EditorGUILayout.TextField("Prefix:", m_Prefix);

            EUtil.PushGUIEnable(m_CurClip != null && bindingInfos.Count > 0);
            if (EUtil.Button("Apply Prefix", Color.green))
            {
                _DoApplyPrefix(bindingInfos, m_Prefix);
            }
            EUtil.PopGUIEnable();
        }
コード例 #3
0
        private void _GUI_ChangePath()
        {
            EditorWindow uaw      = (EditorWindow)EUtil.GetUnityAnimationWindow();
            object       uawstate = EUtil.GetUnityAnimationWindowState(uaw);

            m_CurClip = RCall.GetField("UnityEditorInternal.AnimationWindowState",
                                       "m_ActiveAnimationClip", uawstate) as AnimationClip;

            //1. collect the TrPaths from active curves
            List <EditorCurveBinding> bindingInfos = new List <EditorCurveBinding>();

            IList curves = (IList)RCall.GetProp("UnityEditorInternal.AnimationWindowState", "activeCurves", uawstate);

            if (curves.Count <= 0)
            {
                EditorGUILayout.LabelField("Please Select a Curve first...");
                return;
            }

            EditorCurveBinding theBinding   = (EditorCurveBinding)RCall.GetProp("UnityEditorInternal.AnimationWindowCurve", "binding", curves[0]);
            string             toChangePath = theBinding.path;

            IList allCurves = (IList)RCall.GetProp("UnityEditorInternal.AnimationWindowState", "allCurves", uawstate);

            foreach (var oneUAWCurve in allCurves)
            {
                EditorCurveBinding oneBinding = (EditorCurveBinding)RCall.GetProp("UnityEditorInternal.AnimationWindowCurve", "binding", oneUAWCurve);
                if (oneBinding.path == toChangePath)
                {
                    bindingInfos.Add(oneBinding);
                }
            }

            //2. display
            EditorGUILayout.LabelField("Affected curves:");
            m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos, false, true, GUILayout.Height(200f));
            {
                foreach (var oneInfo in bindingInfos)
                {
                    EditorCurveBinding oneBinding = oneInfo;
                    GUILayout.BeginHorizontal();
                    {
                        EUtil.PushContentColor(Color.yellow);
                        GUILayout.Label(oneBinding.path);
                        EUtil.PopContentColor();
                        EUtil.PushContentColor(Color.green);
                        GUILayout.Label(oneBinding.propertyName);
                        EUtil.PopContentColor();
                    }
                    GUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndScrollView();

            //3. apply prefix
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("R", GUILayout.Width(20)))
            {
                GUIUtility.keyboardControl = 0;
                m_NewPath = toChangePath;
            }
            m_NewPath = EditorGUILayout.TextField("New Path:", m_NewPath);
            EditorGUILayout.EndHorizontal();

            EUtil.PushGUIEnable(m_CurClip != null && bindingInfos.Count > 0);
            if (EUtil.Button("Change Path!", Color.green))
            {
                _DoChangePath(bindingInfos, m_NewPath);
            }
            EUtil.PopGUIEnable();
        }