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); } }
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); } }
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); }
public ObjectFieldSelector(ObjectRuntimeField objectField) { m_ObjectField = objectField; }