Пример #1
0
        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
        }
Пример #2
0
        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
        }