private bool DrawSelectValueName(System.Reflection.FieldInfo filed, Rect rect, object o) { #region Select Value Name ValueNameSelectAttribute selectVarName = Attribute.GetCustomAttribute(filed, typeof(ValueNameSelectAttribute)) as ValueNameSelectAttribute; if (selectVarName != null) { //选择值 Dialog dialog = _currentNode.GetContent() as Dialog; if (dialog == null) { return(false); } string[] keys = selectVarName.GetValueNameList(dialog); int index = Array.FindIndex <string>(keys, (k) => k == (string)filed.GetValue(o)); if (index == -1) { index = 0; } index = EditorGUI.Popup(rect, index, keys); if (keys.Length > 0) { filed.SetValue(o, keys[index]); } return(true); } return(false); #endregion }
private bool DrawSelectValueName(System.Reflection.FieldInfo filed, Rect rect, object o) { #region Select Value Name ValueNameSelectAttribute selectVarName = Attribute.GetCustomAttribute(filed, typeof(ValueNameSelectAttribute)) as ValueNameSelectAttribute; if (selectVarName != null) { //选择值 Mission mission = _currentNode.GetContent() as Mission; if (mission == null) { return(false); } string[] keys = selectVarName.GetValueNameList(mission); int index = Array.FindIndex <string>(keys, (k) => k == (string)filed.GetValue(o)); if (index == -1) { index = 0; } index = EditorGUI.Popup(rect, index, keys); if (keys.Length > 0) { filed.SetValue(o, keys[index]); } //选择变量作用域域 //>>>>失败,Attribute似乎不能保存修改后的数据 //Vector2 size = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Scene).label.CalcSize(new GUIContent(filed.Name)); //EditorGUI.LabelField(GetGUILeftScrollAreaRect(size.x, size.y, size.x > 60), "Value Scope"); //rect = GetGUILeftScrollAreaRect(60, 150, 18); ////selectVarName._valueScope = ValueScope.Story; //selectVarName._valueScope = (ValueScope)EditorGUI.EnumPopup(rect, selectVarName._valueScope); return(true); } return(false); #endregion }
protected void DuplicateNode(NodeModifier targetNode) { NodeModifier node = ReflectionHelper.CreateInstance <NodeModifier>(targetNode.GetType().FullName); JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(targetNode), node); node._position = new Vector2(node._position.x + 10, node._position.y + 10); if (targetNode.Parent != null) { NodeModifier.SetParent(node, targetNode.Parent); } else if (targetNode.Content != null) { NodeModifier.SetContent(node, targetNode.Content); } DragModifier d = node.GetContent() as DragModifier; node.SetID(d.GenerateID()); }