示例#1
0
        public void EmbeddedObjectEditor(Object obj, Rect rect, float leftMargin = 0)
        {
            if (obj == null)
            {
                return;
            }

            Editor editor = null;
            string key    = GenerateKey(obj);

            EditorCache.GetCachedValue("NUIEditor", ref editor, key);
            NUIEditor nuiEditor = editor as NUIEditor;

            if (nuiEditor == null)
            {
                nuiEditor = Editor.CreateEditor(obj) as NUIEditor;

                if (nuiEditor == null)
                {
                    Debug.LogError("Failed to create scriptable object editor.");
                    return;
                }

                EditorCache.SetCachedValue("NUIEditor", nuiEditor, GenerateKey(obj));
            }

            rect.y += 8;

            if (nuiEditor != null)
            {
                Space();
                nuiEditor.drawer.customPositionRect = positionRect;
                nuiEditor.drawer.parentKey          = GenerateKey();
                nuiEditor.OnInspectorNUI();

                float editorHeight = GetHeight(key);
                GUILayout.Space(
                    -editorHeight); // Negate space that embedded editor has already added to prevent overly-large final editor
                AdvancePosition(editorHeight);
            }
            else
            {
                Debug.LogError("Cannot draw null editor.");
            }

            UpdateCachedKey();
        }
示例#2
0
        public void EndEditor(NUIEditor nuiEditor = null)
        {
            if (totalHeight > 32f)
            {
                totalHeight += 5; // Add padding if expanded
            }

            if (EditorGUI.EndChangeCheck())
            {
                if (serializedObject.targetObject != null)
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }

            SetHeight(totalHeight);
            GUILayout.Space(totalHeight);
        }