private LevelEditorComponentUI GetComponentUI() { LevelEditorComponentUI result = pooledComponents.Count > 0 ? pooledComponents.Pop() : Instantiate(componentPrefab, content); result.transform.SetAsLastSibling(); result.gameObject.SetActive(true); activeComponents.Add(result); return(result); }
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]); } } } } }