Ejemplo n.º 1
0
 protected bool TryGetField <T>(ExposedField property, out LevelEditorInspectorField field)
 {
     if (Inspector.HasField(typeof(T)))
     {
         field = Inspector.GetField(typeof(T), content);
         field.Bind(property, Exposed);
         return(true);
     }
     else
     {
         field = null;
         return(false);
     }
 }
Ejemplo n.º 2
0
        public void BindObject(ILevelEditorObject target)
        {
            boundItem = target;

            for (int i = activeFields.Count - 1; i >= 0; i--)
            {
                PoolField(activeFields[i]);
            }

            for (int i = 0; i < activeComponents.Count; i++)
            {
                if (activeComponents[i].Editor != null)
                {
                    activeComponents[i].Editor.Deconstruct();
                }

                pooledComponents.Push(activeComponents[i]);
                activeComponents[i].gameObject.SetActive(false);
            }

            activeComponents.Clear();

            if (objectInfoHolder != null)
            {
                objectInfoHolder.SetActive(target != null);
            }

            if (target != null)
            {
                if (objectActiveToggle != null)
                {
                    objectActiveToggle.SetIsOnWithoutNotify(target.MyGameObject.activeSelf);
                }

                if (objectNameField != null)
                {
                    objectNameField.SetTextWithoutNotify(target.MyGameObject.name);
                }

                IExposedToLevelEditor[] components = target.GetExposedComponents();
                for (int i = 0; i < components.Length; i++)
                {
                    if (!components[i].HasVisibleFields)
                    {
                        continue;
                    }

                    if (!includeTransform && components[i].ComponentType == typeof(Transform))
                    {
                        continue;
                    }

                    LevelEditorComponentUI compUI = GetComponentUI();
                    compUI.Title = components[i].ComponentName;

                    if (LevelEditorComponentEditor.TryGetEditor(components[i].ComponentType, out LevelEditorComponentEditor editor))
                    {
                        editor.Initialize(this, (Component)components[i], components[i], compUI.FieldHolder);
                        editor.BuildUI();
                        compUI.Editor = editor;
                    }
                    else
                    {
                        IReadOnlyList <ExposedField> properties = components[i].GetProperties();
                        for (int j = 0; j < properties.Count; j++)
                        {
                            if (!properties[j].IsVisible)
                            {
                                continue;
                            }

                            if (!HasField(properties[j].Type))
                            {
                                continue;
                            }

                            LevelEditorInspectorField field = GetField(properties[j].Type, compUI.FieldHolder);
                            field.Depth = 0;
                            field.Bind(properties[j], components[i]);
                        }
                    }
                }
            }
        }