/// <summary> Рендерит Setter переменной. </summary> public void RenderVariableSetter() { VariableSetter node = Render(Prefabs.Nodes.VariableSetter).GetComponent <VariableSetter>(); node.Initialize(variable); Manager.ContextManager.DestroyMenu(); }
public void setVariable <T>(string name, T value) { bool shouldSetVariable = true; if (_setters.ContainsKey(name)) // call the setter first { VariableSetter <T> setter = (VariableSetter <T>)_setters[name]; shouldSetVariable = setter(value); } if (shouldSetVariable) { _variables[name] = value; } }
protected void addSetter <T>(string variableName, VariableSetter <T> setter) { _setters[variableName] = setter; }
public bool SetVariable(String key, VariableSetter setter) { _variableSetters.Add(key, setter); return(UpdateVariable(key)); }
void DrawInspector() { if (selectedNode == null) { return; } // Debug.Log (selectedNode); // if (Event.current.type != EventType.Repaint || Event.current.type != EventType.Layout || Event.current.type != ) // return; GUIStyle nodeTypeStyle = new GUIStyle(EditorStyles.label); nodeTypeStyle.alignment = TextAnchor.UpperCenter; nodeTypeStyle.fontStyle = FontStyle.Bold; EditorGUILayout.LabelField(selectedNode.Id, nodeTypeStyle); DrawId(); if (_fields != null) { for (int i = 0; i < _fields.Count; i++) { EditorGUILayout.Separator(); EditorGUILayout.BeginVertical(); FieldInfo field = _fields[i]; string fieldName = field.Name; NodeField nodeField = _fieldToAttributeDict[field]; if (nodeField.GetType() == typeof(NodeField)) { CustomFieldDrawer customFieldDrawer = CustomFieldDrawerManager.GetCustomFieldDrawer(field.FieldType); if (customFieldDrawer == null) { // draw normally if you can...? if (field.FieldType == typeof(bool)) { field.SetValue(selectedNode, EditorGUILayout.ToggleLeft(nodeField.label, (bool)field.GetValue(selectedNode))); } } else { customFieldDrawer.targetField = field; customFieldDrawer.targetNode = selectedNode; customFieldDrawer.Draw(); } } else if (nodeField.GetType() == typeof(VariableGetter)) { VariableGetter getterAttr = (VariableGetter)nodeField; if (getterAttr.overrideField == null) { // no override just draw normal DrawVariableDropdown(field, getterAttr); } else { string fieldValue = (string)field.GetValue(selectedNode); if (fieldValue == null) { // draw field normally } } } else if (nodeField.GetType() == typeof(VariableSetter)) { VariableSetter setterAttr = (VariableSetter)nodeField; DrawVariableDropdown(field, setterAttr); } EditorGUILayout.EndVertical(); } // EditorGUILayout.BeginVertical(EditorStyles.textArea); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Comments"); GUIStyle commentStyle = new GUIStyle(EditorStyles.textArea); commentStyle.fixedHeight = 100; EditorGUILayout.TextArea("", commentStyle); } if (Application.isPlaying) { EditorGUILayout.TextArea(selectedNode.StateMessage, GUILayout.Height(60)); } if (redrawInspector) { GUI.FocusControl(null); redrawInspector = false; } }
public void setSetter(VariableSetter aVariableSetter) { setter = aVariableSetter; }