public static AxisInputData AxisPopup(AxisInputData _axis, string _title = "", string _hint = "", string _help = "")
        {
            AxisInputData[] _axes = EditorTools.ReadAxes();

            if (_axes.Length == 0)
            {
                _axis.Name = ICEEditorLayout.Text(_title, _hint, _axis.Name, _help);
            }
            else
            {
                string[] _names = new string[_axes.Length];

                for (int i = 0; i < _axes.Length; i++)
                {
                    _names[i] = _axes[i].Name;
                }

                int _selected = ICEEditorLayout.Popup(_title, _hint, EditorTools.StringToIndex(_axis.Name, _names), _names);

                _axis.Copy(_axes[_selected]);

                /*
                 * for( int i = 0 ; i < _axes.Length ; i++ )
                 * {
                 *      if( _axes[i].Name == _names[_selected] )
                 *      {
                 *              _input.Copy( _axes[i] );
                 *      }
                 * }*/
            }

            return(_axis);
        }
Beispiel #2
0
        public static AxisInputData[] ReadAxes()
        {
            var _input_manager = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
            SerializedObject   _input_object = new SerializedObject(_input_manager);
            SerializedProperty _axes_array   = _input_object.FindProperty("m_Axes");

            if (_axes_array.arraySize == 0)
            {
                return(new AxisInputData[0]);
            }

            AxisInputData[] _axes = new AxisInputData[_axes_array.arraySize];

            for (int i = 0; i < _axes_array.arraySize; ++i)
            {
                _axes[i] = new AxisInputData();

                SerializedProperty axis = _axes_array.GetArrayElementAtIndex(i);

                _axes[i].Name  = axis.FindPropertyRelative("m_Name").stringValue;
                _axes[i].Value = axis.FindPropertyRelative("axis").intValue;
                _axes[i].Type  = (AxisInputType)axis.FindPropertyRelative("type").intValue;

                //Debug.Log(_axes[i].Name);
                //Debug.Log(_axes[i].Value);
                //Debug.Log(_axes[i].Type);
            }

            return(_axes);
        }
        public static AxisInputData InputPopup(ICEWorldBehaviour _component, AxisInputData _axis, string _help = "", string _title = "", string _hint = "")
        {
            if (string.IsNullOrEmpty(_title))
            {
                _title = "Input";
            }
            if (string.IsNullOrEmpty(_hint))
            {
                _hint = "";
            }
            if (string.IsNullOrEmpty(_help))
            {
                _help = Info.INPUT_POPUP;
            }

            ICEEditorLayout.BeginHorizontal();
            _axis = AxisPopup(_axis, _title, _hint, "");
            ICEEditorLayout.EndHorizontal(_help);
            return(_axis);
        }