public UdonParameterField(UdonGraph udonGraph, UdonNodeData nodeData) { this.udonGraph = udonGraph; this.nodeData = nodeData; // Get Definition or exit early UdonNodeDefinition definition = UdonEditorManager.Instance.GetNodeDefinition(nodeData.fullName); if (definition == null) { UnityEngine.Debug.LogWarning($"Couldn't create Parameter Field for {nodeData.fullName}"); return; } this.text = (string)nodeData.nodeValues[(int)UdonParameterProperty.ValueIndices.name].Deserialize(); this.typeText = UdonGraphExtensions.PrettyString(definition.name).FriendlyNameify(); this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu)); this.Q("icon").AddToClassList("parameter-" + definition.type); this.Q("icon").visible = true; var textField = (TextField)this.Q("textField"); textField.isDelayed = true; textField.OnValueChanged((e) => { UnityEditor.Undo.RecordObject(udonGraph.graphProgramAsset, "Rename Variable"); // Sanitize value for variable name string newVariableName = e.newValue.SanitizeVariableName(); text = newVariableName; nodeData.nodeValues[(int)UdonParameterProperty.ValueIndices.name] = SerializableObjectContainer.Serialize(newVariableName); }); }
public UdonParameterField(UdonGraph udonGraph, UdonNodeData nodeData) { this.udonGraph = udonGraph; this.nodeData = nodeData; // Get Definition or exit early UdonNodeDefinition definition = UdonEditorManager.Instance.GetNodeDefinition(nodeData.fullName); if (definition == null) { UnityEngine.Debug.LogWarning($"Couldn't create Parameter Field for {nodeData.fullName}"); return; } this.text = (string)nodeData.nodeValues[(int)UdonParameterProperty.ValueIndices.name].Deserialize(); this.typeText = UdonGraphExtensions.PrettyString(definition.name).FriendlyNameify(); this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu)); this.Q("icon").AddToClassList("parameter-" + definition.type); this.Q("icon").visible = true; var textField = (TextField)this.Q("textField"); textField.isDelayed = true; }
public void InitializeGraph(UdonGraphProgramAsset graph, UdonBehaviour udonBehaviour = null) { this._graphAsset = graph; InitializeWindow(); _graphView = _rootView.Children().FirstOrDefault(e => e is UdonGraph) as UdonGraph; if (_graphView == null) { Debug.LogError("GraphView has not been added to the BaseGraph root view!"); return; } _graphView.Initialize(graph, udonBehaviour); _graphStatus.LoadAsset(graph); // Store GUID for this asset to settings for easy reload later if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(graph, out string guid, out long localId)) { Settings.LastGraphGuid = guid; } if (udonBehaviour != null) { Settings.LastUdonBehaviourPath = udonBehaviour.transform.GetHierarchyPath(); Settings.LastUdonBehaviourScenePath = udonBehaviour.gameObject.scene.path; } _graphAssetName.text = graph.name; ShowGraphTools(true); }
public UdonVariablesBlackboard(UdonGraph graph) { _graph = graph; title = "Variables"; name = "Parameters"; scrollable = true; // Remove subtitle var subtitle = this.Query <Label>("subTitleLabel").AtIndex(0); if (subtitle != null) { subtitle.RemoveFromHierarchy(); } // Improve resizer UI style.borderBottomWidth = 1; var resizer = this.Q(null, "resizer"); if (resizer != null) { resizer.style.paddingTop = 0; resizer.style.paddingLeft = 0; } SetPosition(_customData.layout); }
public static UdonComment Create(UdonGraphElementData elementData, UdonGraph graph) { var comment = new UdonComment(elementData.jsonData, graph); comment.UpdateFromData(); graph.MarkSceneDirty(); return(comment); }
public UdonSearchManager(UdonGraph view, UdonGraphWindow window) { _view = view; _window = window; SetupSearchTypes(); view.nodeCreationRequest += OnRequestNodeCreation; }
private void InitializeWindow() { if (_graphView == null) { _graphView = new UdonGraph(this); // we could add the toolbar in here } RemoveIfContaining(_welcomeView); _rootView.Insert(0, _graphView); }
public UdonMinimap(UdonGraph graph) { _graph = graph; name = "UdonMap"; maxWidth = 200; maxHeight = 100; anchored = false; SetPosition(_customData.layout); }
// Build a Group from jsonData, save to userData private UdonGroup(string jsonData, UdonGraph graph) { title = "Group"; _graph = graph; if (!string.IsNullOrEmpty(jsonData)) { EditorJsonUtility.FromJsonOverwrite(jsonData, _customData); } }
// Called from Context menu public static UdonComment Create(string value, Rect position, UdonGraph graph) { var comment = new UdonComment("", graph); // make sure rect size is not 0 position.width = position.width > 0 ? position.width : 128; position.height = position.height > 0 ? position.height : 40; comment._customData.layout = position; comment._customData.title = value; return(comment); }
private UdonComment(string jsonData, UdonGraph graph) { title = "Comment"; name = "comment"; _graph = graph; capabilities |= Capabilities.Selectable | Capabilities.Movable | Capabilities.Deletable | Capabilities.Resizable; pickingMode = PickingMode.Ignore; type = UdonGraphElementType.UdonComment; if (!string.IsNullOrEmpty(jsonData)) { EditorJsonUtility.FromJsonOverwrite(jsonData, _customData); } _mainContainer = new VisualElement(); _mainContainer.StretchToParentSize(); _mainContainer.AddToClassList("mainContainer"); Add(_mainContainer); _label = new Label(); _label.RegisterCallback <MouseDownEvent>(OnLabelClick); _mainContainer.Add(_label); _textField = new TextField(1000, true, false, '*'); _textField.isDelayed = true; // Support IME _textField.RegisterCallback <FocusInEvent>(evt => { Input.imeCompositionMode = IMECompositionMode.On; }); _textField.RegisterCallback <FocusOutEvent>(evt => { SetText(_textField.text); Input.imeCompositionMode = IMECompositionMode.Auto; SwitchToEditMode(false); }); #if UNITY_2019_3_OR_NEWER _textField.RegisterValueChangedCallback((evt) => #else _textField.OnValueChanged((evt) => #endif { SetText(evt.newValue); SwitchToEditMode(false); }); }
public static UdonGroup Create(string value, Rect position, UdonGraph graph) { var group = new UdonGroup("", graph); group.uid = Guid.NewGuid().ToString(); // make sure rect size is not 0 position.width = position.width > 0 ? position.width : 128; position.height = position.height > 0 ? position.height : 128; group._customData.uid = group.uid; group._customData.layout = position; group._customData.title = value; return(group); }
public virtual void Initialize(UdonGraphWindow editorWindow, UdonGraph graphView) { _editorWindow = editorWindow; _graphView = graphView; }
// 0 = Value, 1 = name, 2 = public, 3 = synced, 4 = syncType public UdonParameterProperty(UdonGraph graphView, UdonNodeDefinition definition, UdonNodeData nodeData) { this.graph = graphView; this.definition = definition; this.nodeData = nodeData; // Make sure the incoming nodeData has the right number of nodeValues (super old graphs didn't have sync info) if (this.nodeData.nodeValues.Length != 5) { this.nodeData.nodeValues = GetDefaultNodeValues(); for (int i = 0; i < nodeData.nodeValues.Length; i++) { this.nodeData.nodeValues[i] = nodeData.nodeValues[i]; } } // Public Toggle isPublic = new Toggle { text = "public", value = (bool)GetValue(ValueIndices.isPublic) }; #if UNITY_2019_3_OR_NEWER isPublic.RegisterValueChangedCallback( #else isPublic.OnValueChanged( #endif e => { SetNewValue(e.newValue, ValueIndices.isPublic); }); Add(isPublic); // Is Synced Field isSynced = new Toggle { text = "synced", value = (bool)GetValue(ValueIndices.isSynced), }; #if UNITY_2019_3_OR_NEWER isSynced.RegisterValueChangedCallback( #else isSynced.OnValueChanged( #endif e => { SetNewValue(e.newValue, ValueIndices.isSynced); syncField.visible = e.newValue; }); Add(isSynced); // Sync Field, add to isSynced List <string> choices = new List <string>() { "none", "linear", "smooth" }; syncField = new EditorUI.PopupField <string>(choices, 0) { visible = isSynced.value }; #if UNITY_2019_3_OR_NEWER syncField.RegisterValueChangedCallback( #else syncField.OnValueChanged( #endif e => { SetNewValue(e.newValue, ValueIndices.syncType); }); isSynced.Add(syncField); // Container to show/edit Default Value var friendlyName = UdonGraphExtensions.FriendlyTypeName(definition.type).FriendlyNameify(); defaultValueContainer = new VisualElement(); defaultValueContainer.Add( new Label("default value") { name = "default-value-label" }); // Generate Default Value Field var value = TryGetValueObject(out object result); _inputField = UdonFieldFactory.CreateField( definition.type, result, newValue => SetNewValue(newValue, ValueIndices.value) ); if (_inputField != null) { defaultValueContainer.Add(_inputField); Add(defaultValueContainer); } }
public static UdonGroup Create(UdonGraphElementData elementData, UdonGraph graph) { return(new UdonGroup(elementData.jsonData, graph)); }
// 0 = Value, 1 = name, 2 = public, 3 = synced, 4 = syncType public UdonParameterProperty(UdonGraph graphView, UdonNodeDefinition definition, UdonNodeData nodeData) { this.graph = graphView; this.definition = definition; this.nodeData = nodeData; // Make sure the incoming nodeData has the right number of nodeValues (super old graphs didn't have sync info) if (this.nodeData.nodeValues.Length != 5) { this.nodeData.nodeValues = GetDefaultNodeValues(); for (int i = 0; i < nodeData.nodeValues.Length; i++) { this.nodeData.nodeValues[i] = nodeData.nodeValues[i]; } } // Public Toggle isPublic = new EngineUI.Toggle { text = "public", value = (bool)GetValue(ValueIndices.isPublic) }; isPublic.OnValueChanged(e => { SetNewValue(e.newValue, ValueIndices.isPublic); }); Add(isPublic); // Is Synced Field isSynced = new EngineUI.Toggle { text = "synced", value = (bool)GetValue(ValueIndices.isSynced), }; isSynced.OnValueChanged(e => { SetNewValue(e.newValue, ValueIndices.isSynced); syncField.visible = e.newValue; }); Add(isSynced); // Sync Field, add to isSynced List <string> choices = new List <string>() { "none", "linear", "smooth" }; syncField = new EditorUI.PopupField <string>(choices, 0) { visible = isSynced.value }; syncField.OnValueChanged(e => { SetNewValue(e.newValue, ValueIndices.syncType); }); isSynced.Add(syncField); // Container to show/edit Default Value var friendlyName = UdonGraphExtensions.FriendlyTypeName(definition.type).FriendlyNameify(); defaultValueContainer = new VisualElement { new Label("default value") { name = "default-value-label" } }; var field = GetTheRightField(definition.type); if (field != null) { // TODO: need to handle cases where we can't generate the field above defaultValueContainer.Add(field); Add(defaultValueContainer); } }
// 0 = Value, 1 = name, 2 = public, 3 = synced, 4 = syncType public UdonParameterProperty(UdonGraph graphView, UdonNodeDefinition definition, UdonNodeData nodeData) { this.graph = graphView; this.definition = definition; this.nodeData = nodeData; string friendlyName = UdonGraphExtensions.FriendlyTypeName(definition.type).FriendlyNameify(); // Public Toggle isPublic = new Toggle { text = "public", value = (bool)GetValue(ValueIndices.isPublic) }; #if UNITY_2019_3_OR_NEWER isPublic.RegisterValueChangedCallback( #else isPublic.OnValueChanged( #endif e => { SetNewValue(e.newValue, ValueIndices.isPublic); }); Add(isPublic); if (UdonNetworkTypes.CanSync(definition.type)) { // Is Synced Field isSynced = new Toggle { text = "synced", value = (bool)GetValue(ValueIndices.isSynced), name = "syncToggle", }; #if UNITY_2019_3_OR_NEWER isSynced.RegisterValueChangedCallback( #else isSynced.OnValueChanged( #endif e => { SetNewValue(e.newValue, ValueIndices.isSynced); syncField.visible = e.newValue; }); // Sync Field, add to isSynced List <string> choices = new List <string>() { "none" }; if (UdonNetworkTypes.CanSyncLinear(definition.type)) { choices.Add("linear"); } if (UdonNetworkTypes.CanSyncSmooth(definition.type)) { choices.Add("smooth"); } syncField = new EditorUI.PopupField <string>(choices, 0) { visible = isSynced.value, }; syncField.Insert(0, new Label("smooth:")); #if UNITY_2019_3_OR_NEWER syncField.RegisterValueChangedCallback( #else syncField.OnValueChanged( #endif e => { SetNewValue(e.newValue, ValueIndices.syncType); }); // Only show sync smoothing dropdown if there are choices to be made if (choices.Count > 1) { isSynced.Add(syncField); } Add(isSynced); } else { // Cannot Sync SetNewValue(false, ValueIndices.isSynced); Add(new Label($"{friendlyName} cannot be synced.")); } // Container to show/edit Default Value defaultValueContainer = new VisualElement(); defaultValueContainer.Add( new Label("default value") { name = "default-value-label" }); // Generate Default Value Field var value = TryGetValueObject(out object result); _inputField = UdonFieldFactory.CreateField( definition.type, result, newValue => SetNewValue(newValue, ValueIndices.value) ); if (_inputField != null) { defaultValueContainer.Add(_inputField); Add(defaultValueContainer); } }