/// <summary> /// Converts the Object into an string ready to write into a YAML FILE /// </summary> /// <returns></returns> public static string ConfigToYAML(Gaze_InputConfig _config) { string toYAML = ""; toYAML += String.Format(" - {0}: {1}{2}", Gaze_InputConfigConstants.NAME_SERIALIZED_VERSION, _config.serializedVersion, Environment.NewLine); toYAML += PropToString(Gaze_InputConfigConstants.NAME_NAME, _config.m_Name); toYAML += PropToString(Gaze_InputConfigConstants.NAME_DESCRIPTIVE_NAME, _config.descriptiveName); toYAML += PropToString(Gaze_InputConfigConstants.NAME_DESCRIPTIVE_NEGATIVE_NAME, _config.descriptiveNegativeName); toYAML += PropToString(Gaze_InputConfigConstants.NAME_NEGATIVE_BUTTON, _config.negativeButton); toYAML += PropToString(Gaze_InputConfigConstants.NAME_POSITIVE_BUTTON, _config.positiveButton); toYAML += PropToString(Gaze_InputConfigConstants.NAME_ALT_NEGATIVE_BUTTON, _config.altNegativeButton); toYAML += PropToString(Gaze_InputConfigConstants.NAME_ALT_POSITIVE_BUTTON, _config.altPositiveButton); toYAML += PropToString(Gaze_InputConfigConstants.NAME_GRAVITY, _config.gravity); toYAML += PropToString(Gaze_InputConfigConstants.NAME_DEAD, _config.dead); toYAML += PropToString(Gaze_InputConfigConstants.NAME_SENSITIVITY, _config.sensitivity); toYAML += PropToString(Gaze_InputConfigConstants.NAME_SNAP, _config.snap); toYAML += PropToString(Gaze_InputConfigConstants.NAME_INVERT, _config.invert); toYAML += PropToString(Gaze_InputConfigConstants.NAME_TYPE, _config.type); toYAML += PropToString(Gaze_InputConfigConstants.NAME_AXIS, _config.axis); toYAML += PropToString(Gaze_InputConfigConstants.NAME_JOY_NUM, _config.joyNum); return(toYAML); }
/// <summary> /// Deserializes the InputManager.asset and returns a list of Gaze_InputConfigs /// </summary> /// <param name="_path"></param> /// <returns></returns> public static List <Gaze_InputConfig> ReadBinaryInputs(string _path) { List <Gaze_InputConfig> inputConfigs = new List <Gaze_InputConfig>(); var inputManager = AssetDatabase.LoadAllAssetsAtPath(_path)[0]; SerializedObject obj = new SerializedObject(inputManager); SerializedProperty axisArray = obj.FindProperty("m_Axes"); if (axisArray.arraySize == 0) { Debug.Log("No Axes"); } for (int i = 0; i < axisArray.arraySize; ++i) { SerializedProperty inputConfig = axisArray.GetArrayElementAtIndex(i); Gaze_InputConfig conf = new Gaze_InputConfig(inputConfig); inputConfigs.Add(conf); } return(inputConfigs); }