public ObjectRuntimeField(string label) : base(label, null) { var visualInput = Children().FirstOrDefault(); if (visualInput == null) { return; } visualInput.focusable = false; labelElement.focusable = false; AddToClassList(ussClassName); labelElement.AddToClassList(labelUssClassName); allowSceneObjects = true; m_ObjectFieldDisplay = new ObjectFieldDisplay(this) { focusable = true }; m_ObjectFieldDisplay.AddToClassList(objectUssClassName); var objectSelector = new ObjectFieldSelector(this); objectSelector.AddToClassList(selectorUssClassName); visualInput.AddToClassList(inputUssClassName); visualInput.Add(m_ObjectFieldDisplay); visualInput.Add(objectSelector); }
/// <summary> /// Constructor. /// </summary> public ObjectField(string label) : base(label, null) { visualInput.focusable = false; labelElement.focusable = false; AddToClassList(ussClassName); labelElement.AddToClassList(labelUssClassName); allowSceneObjects = true; m_objectType = typeof(Object); m_ObjectFieldDisplay = new ObjectFieldDisplay(this) { focusable = true }; m_ObjectFieldDisplay.AddToClassList(objectUssClassName); var objectSelector = new ObjectFieldSelector(this); objectSelector.AddToClassList(selectorUssClassName); visualInput.AddToClassList(inputUssClassName); visualInput.Add(m_ObjectFieldDisplay); visualInput.Add(objectSelector); // Get notified when hierarchy or project changes so we can update the display to handle renamed/missing objects. // This event is occasionally triggered before the reference in memory is updated, so we give it time to process. m_AsyncOnProjectOrHierarchyChangedCallback = () => schedule.Execute(m_OnProjectOrHierarchyChangedCallback); m_OnProjectOrHierarchyChangedCallback = () => m_ObjectFieldDisplay.Update(); RegisterCallback <AttachToPanelEvent>((evt) => { EditorApplication.projectChanged += m_AsyncOnProjectOrHierarchyChangedCallback; EditorApplication.hierarchyChanged += m_AsyncOnProjectOrHierarchyChangedCallback; }); RegisterCallback <DetachFromPanelEvent>((evt) => { EditorApplication.projectChanged -= m_AsyncOnProjectOrHierarchyChangedCallback; EditorApplication.hierarchyChanged -= m_AsyncOnProjectOrHierarchyChangedCallback; }); }
public ObjectField(string label) : base(label, null) { visualInput.focusable = false; labelElement.focusable = false; AddToClassList(ussClassName); labelElement.AddToClassList(labelUssClassName); allowSceneObjects = true; m_ObjectFieldDisplay = new ObjectFieldDisplay(this) { focusable = true }; m_ObjectFieldDisplay.AddToClassList(objectUssClassName); var objectSelector = new ObjectFieldSelector(this); objectSelector.AddToClassList(selectorUssClassName); visualInput.AddToClassList(inputUssClassName); visualInput.Add(m_ObjectFieldDisplay); visualInput.Add(objectSelector); }