コード例 #1
0
        public override void OnInspectorGUI()
        {
                        #if UNITY_5_6_OR_NEWER
            serializedObject.UpdateIfRequiredOrScript();
                        #else
            serializedObject.UpdateIfDirtyOrScript();
                        #endif

            EditorGUIUtility.labelWidth = 50;

            GUI.backgroundColor = Color.Lerp(Color.black, Color.gray, 1);
            GUILayout.BeginVertical(I2_InspectorTools.GUIStyle_Background, GUILayout.Height(1));
            GUI.backgroundColor = Color.white;


            //--[ HEADER ]----------------------
            if (GUILayout.Button("SE Animation", I2_InspectorTools.GUIStyle_Header))
            {
                //Application.OpenURL(SE_InspectorTools.HelpURL_Documentation);
            }

            GUILayout.Space(5);

            //--[ INSPECTOR ]---------------------

            EditorGUI.BeginChangeCheck();

            mInspector.OnGUI_Animation();

            if (EditorGUI.EndChangeCheck() || mDirty)
            {
                mDirty = false;
                var data = SE_Animation.SaveSerializedData(mInspector.mAnimation);
                if (mProp_SerializedData.stringValue != data)
                {
                    mProp_SerializedData.stringValue = data;
                    //Debug.Log(data);
                }
            }

            //--[ FOOTER ]-------------------------
            GUILayout.Space(10);
            GUILayout.FlexibleSpace();

            GUITools.OnGUI_Footer("I2 TextAnimation", I2_InspectorTools.GetVersion(), I2_InspectorTools.HelpURL_forum, I2_InspectorTools.HelpURL_Documentation, I2_InspectorTools.HelpURL_AssetStore);

            EditorGUIUtility.labelWidth = 0;

            GUILayout.EndVertical();

            serializedObject.ApplyModifiedProperties();
        }
コード例 #2
0
        public void OnGUI_AnimationSlot()
        {
            var prop_Slot          = mSerialized_AnimationSlots.GetArrayElementAtIndex(mAnimationsReorderableList.index);
            var prop_SlotPreset    = prop_Slot.FindPropertyRelative("_Preset");
            var prop_SlotLocalData = prop_Slot.FindPropertyRelative("_LocalSerializedData");

            if (mEditor_SelectedAnim == null || iCurrentAnimationSlot != mAnimationsReorderableList.index)
            {
                iCurrentAnimationSlot = mAnimationsReorderableList.index;

                if (prop_SlotPreset.objectReferenceValue != null)
                {
                    mSerializedObject_SelectedAnim = new SerializedObject(prop_SlotPreset.objectReferenceValue);
                }
                else
                {
                    mSerializedObject_SelectedAnim = null;
                }

                DestroyAnimationInspector();

                mEditor_SelectedAnim = new SE_Animation_Inspector(mTarget._AnimationSlots[iCurrentAnimationSlot]._Animation /*CreateAnimation()*/, mTarget);
            }

            if (prop_SlotPreset.objectReferenceValue != null && mSerializedObject_SelectedAnim != null)
            {
                                #if UNITY_5_6_OR_NEWER
                mSerializedObject_SelectedAnim.UpdateIfRequiredOrScript();
                                #else
                mSerializedObject_SelectedAnim.UpdateIfDirtyOrScript();
                                #endif
            }

            GUILayout.Space(10);


            //GUITools.DrawHeader("Animation", true);
            var boxArea = new GUIStyle("Box");
            boxArea.overflow = new RectOffset(2, 2, 0, 0);
            bool deselectAnimation = false;
            GUILayout.BeginHorizontal(boxArea);
            GUILayout.Toggle(true, "Animation", EditorStyles.foldout);
            GUILayout.FlexibleSpace();
            deselectAnimation = GUILayout.Button("X", EditorStyles.miniButton);
            GUILayout.EndHorizontal();

            GUILayout.Space(-4);


            GUI.backgroundColor = GUITools.DarkGray;
            GUILayout.BeginVertical(/*EditorStyles.textArea, */ GUILayout.Height(1));
            GUI.backgroundColor = Color.white;

            EditorGUI.BeginChangeCheck();
            mEditor_SelectedAnim.OnGUI_Animation();

            if (EditorGUI.EndChangeCheck() || SE_AnimationPreset_Inspector.mDirty)
            {
                SE_AnimationPreset_Inspector.mDirty = false;

                var data = SE_Animation.SaveSerializedData(mEditor_SelectedAnim.mAnimation);
                if (prop_SlotLocalData.stringValue != data)
                {
                    prop_SlotLocalData.stringValue = data;
                    //Debug.Log(data);
                }

                if (prop_SlotPreset.objectReferenceValue != null)
                {
                    var prop_PresetData = mSerializedObject_SelectedAnim.FindProperty("mSerializedData");
                    if (prop_PresetData.stringValue != data)
                    {
                        prop_PresetData.stringValue = data;
                        mSerializedObject_SelectedAnim.ApplyModifiedProperties();
                        //mTarget._AnimationSlots[iCurrentAnimationSlot].CreateAnimation();
                    }
                }
            }
            if (mEditor_SelectedAnim.mAnimation.IsPlaying)
            {
                mMakeMaterialDirty = mMakeVerticesDirty = true;
            }


            GUITools.CloseHeader();

            if (deselectAnimation)
            {
                DeselectAnimation();
            }
        }