コード例 #1
0
ファイル: ObjectControl.cs プロジェクト: hagusen/AI-Testing
        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);
        }
コード例 #2
0
        /// <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;
            });
        }
コード例 #3
0
        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);
        }