示例#1
0
 void Init(bool autoLayout)
 {
     if (config.type is RuntimeType)
     {
         if (config.owner.targetNode.owner.IsRuntimeGraph())
         {
             var field = new ObjectRuntimeField()
             {
                 objectType        = config.type as RuntimeType,
                 value             = config.value as UnityEngine.Object,
                 allowSceneObjects = uNodeEditorUtility.IsSceneObject(config.owner.targetNode)
             };
             field.RegisterValueChangedCallback((e) => {
                 config.OnValueChanged(e.newValue);
                 MarkDirtyRepaint();
             });
             Add(field);
         }
         else
         {
             var button = new Label()
             {
                 text = "null"
             };
             button.AddToClassList("PopupButton");
             button.EnableInClassList("Layout", autoLayout);
             Add(button);
         }
     }
     else
     {
         button = new PopupElement();
         button.EnableInClassList("Layout", autoLayout);
         button.AddManipulator(new LeftMouseClickable(OnClick));
         {
             if (config.value != null && config.value as uNodeRoot == config.owner.targetNode?.owner)
             {
                 button.text = "this";
             }
             else
             {
                 button.text = uNode.uNodeUtility.GetDisplayName(config.value);
             }
             button.tooltip = button.text;
             if (button.text.Length > 25)
             {
                 button.text = button.text.Substring(0, 25);
             }
         }
         Add(button);
     }
 }
示例#2
0
 void Init(bool autoLayout)
 {
     if (config.type is RuntimeType)
     {
         if (config.owner.targetNode.owner.IsRuntimeGraph())
         {
             var field = new ObjectRuntimeField()
             {
                 objectType        = config.type as RuntimeType,
                 value             = config.value as UnityEngine.Object,
                 allowSceneObjects = uNodeEditorUtility.IsSceneObject(config.owner.targetNode)
             };
             field.RegisterValueChangedCallback((e) => {
                 config.OnValueChanged(e.newValue);
                 MarkDirtyRepaint();
             });
             Add(field);
         }
         else
         {
             var button = new Label()
             {
                 text = "null"
             };
             button.AddToClassList("PopupButton");
             button.EnableInClassList("Layout", autoLayout);
             Add(button);
             // if(config.value != null) {
             //  try {
             //      config.OnValueChanged(null);
             //  } catch{ }
             // }
         }
     }
     else
     {
         ObjectField field = new ObjectField()
         {
             objectType = config.type,
             value      = config.value as UnityEngine.Object,
         };
         field.RegisterValueChangedCallback((e) => {
             config.OnValueChanged(e.newValue);
             MarkDirtyRepaint();
         });
         field.allowSceneObjects = uNodeEditorUtility.IsSceneObject(config.owner.targetNode) && !GraphUtility.IsTempGraphObject(config.owner.targetNode.gameObject);
         Add(field);
     }
 }
示例#3
0
            public ObjectFieldDisplay(ObjectRuntimeField objectField)
            {
                AddToClassList(ussClassName);
                m_ObjectIcon = new Image {
                    scaleMode = ScaleMode.ScaleAndCrop, pickingMode = PickingMode.Ignore
                };
                m_ObjectIcon.AddToClassList(iconUssClassName);
                m_ObjectLabel = new Label {
                    pickingMode = PickingMode.Ignore
                };
                m_ObjectLabel.AddToClassList(labelUssClassName);
                m_ObjectField = objectField;

                Update();

                Add(m_ObjectIcon);
                Add(m_ObjectLabel);
            }
示例#4
0
 public ObjectFieldSelector(ObjectRuntimeField objectField)
 {
     m_ObjectField = objectField;
 }