public override void OnInspectorGUI()
        {
            serializedObject.Update();
            GUILayout.Space(10);
            for (int i = 0; i < m_PostEffects.arraySize; i++)
            {
                var eff = m_PostEffects.GetArrayElementAtIndex(i);
                if (eff.objectReferenceValue == null)
                {
                    if (i == dropIndex)
                    {
                        dropIndex = -1;
                    }
                    m_PostEffects.DeleteArrayElementAtIndex(i);
                    break;
                }
                drop = dropIndex == i;
                EditorGUILayout.BeginVertical(drop ? "flow overlay box" : "box");
                int  ret  = QuickGUI.TitleBarWithBtn(eff.objectReferenceValue.name, 12, 15, "OL Minus", "OL Plus");
                bool over = false;
                if (ret == 0)
                {
                    dropIndex = i;
                    if (eff.objectReferenceValue != null)
                    {
                        EditorGUIUtility.PingObject(eff.objectReferenceValue);
                    }
                }
                else if (ret == 1)
                {
                    m_PostEffects.DeleteArrayElementAtIndex(i);
                    over = true;
                }
                else if (drop)
                {
                    var editor = GetEditor(eff.objectReferenceValue);
                    if (editor != null)
                    {
                        editor.OnInspectorGUI();
                    }
                }
                EditorGUILayout.EndVertical();
                if (over)
                {
                    break;
                }
            }
            GUILayout.Space(5);
            var rect = EditorGUILayout.BeginHorizontal();

            newAsset = EditorGUILayout.ObjectField("New Effect", newAsset, typeof(CameraPostProcessingAsset), false) as CameraPostProcessingAsset;
            bool newpop = false;

            if (GUILayout.Button("Add", GUILayout.Width(40)))
            {
                if (newAsset == null)
                {
                    rect.x = rect.xMax;
                    newpop = true;
                }
                else
                {
                    var index = m_PostEffects.arraySize;
                    dropIndex = index;
                    m_PostEffects.InsertArrayElementAtIndex(index);
                    m_PostEffects.GetArrayElementAtIndex(index).objectReferenceValue = newAsset;
                    newAsset = null;
                }
            }
            EditorGUILayout.EndVertical();
            serializedObject.ApplyModifiedProperties();
            if (newpop)
            {
                EditorUtility.DisplayCustomMenu(rect, mAssetNames, -1, OnAddEffectSelected, null);
            }
        }
Пример #2
0
 public override void OnInspectorGUI()
 {
     mPos = EditorGUILayout.BeginScrollView(mPos);
     if (mTarget.m_Anims != null)
     {
         for (int i = 0; i < mTarget.m_Anims.Length; i++)
         {
             bool drop = mDropIndex == i;
             EditorGUILayout.BeginVertical(drop ? "flow overlay box" : "box");
             var anim = mTarget.m_Anims[i];
             int ret  = QuickGUI.TitleBarWithBtn(anim.m_Name, 12, 15, "OL Minus", "OL Plus");
             if (ret == 0)
             {
                 mDropIndex = i;
                 GUI.FocusControl(null);
             }
             if (drop)
             {
                 var str = EditorGUILayout.TextField("Name", anim.m_Name ?? "");
                 mDirty     |= str != anim.m_Name;
                 anim.m_Name = str;
                 var dur = Mathf.Max(0.0001f, EditorGUILayout.FloatField("Duration", anim.m_Duration));
                 mDirty         |= dur != anim.m_Duration;
                 anim.m_Duration = dur;
                 OnFrameGUI(anim);
             }
             if (drop)
             {
                 GUILayout.Space(10);
             }
             EditorGUILayout.EndVertical();
             if (ret == 1)
             {
                 RemoveAnim(i);
                 mDirty = true;
                 GUI.FocusControl(null);
                 break;
             }
             else if (ret == 2)
             {
                 InsertAnim(i, anim);
                 mDropIndex = i;
                 mDirty     = true;
                 GUI.FocusControl(null);
                 break;
             }
         }
     }
     EditorGUILayout.BeginVertical("U2D.createRect");
     if (QuickGUI.TitleBar("New Emoji Animation", 13) == 0)
     {
         InsertAnim(mTarget.m_Anims == null ? 0 : mTarget.m_Anims.Length);
         mDropIndex = mTarget.m_Anims.Length - 1;
         mDirty     = true;
         GUI.FocusControl(null);
     }
     if (mDirty)
     {
         mDirty = false;
         EditorUtility.SetDirty(target);
         serializedObject.Update();
     }
     EditorGUILayout.EndVertical();
     EditorGUILayout.EndScrollView();
 }