Esempio n. 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);
     }
 }
Esempio n. 2
0
        void Init()
        {
            style.flexDirection   = FlexDirection.Row;
            popupElement          = new PopupElement();
            popupElement.richText = UIElementUtility.Theme.coloredReference;
            popupElement.visible  = false;
            popupElement.AddManipulator(new LeftMouseClickable(PopupClick));
            popupElement.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
            member = config.value as MemberData;
            if (member == null)
            {
                member = MemberData.none;
                config.OnValueChanged(member);
            }

            if (config.filter == null)
            {
                config.filter = new FilterAttribute();
            }
            UpdateControl();
        }