/// <summary> /// Get X, Y, Z coordinates. /// </summary> /// <param name="title">Title for action field.</param> /// <param name="actionParams">Action field parameters.</param> /// <param name="actionFieldA">Action field parameters.</param> /// <param name="actionFieldB">Action field parameters.</param> /// <param name="actionFieldC">Action field parameters.</param> /// <param name="actionFieldD">Action field parameters.</param> /// <param name="actionFieldE">Action field parameters.</param> /// <param name="actionFieldF">Action field parameters.</param> /// <param name="titleToLeft">Show the title on the left?</param> public static void BuildField(string title, HeroActionParams actionParams, HeroActionField actionFieldA, HeroActionField actionFieldB, HeroActionField actionFieldC, HeroActionField actionFieldD, HeroActionField actionFieldE, HeroActionField actionFieldF, bool titleToLeft = false) { if (title != "") { SimpleLayout.Label(title); } bool changeX = GetBoolValue.BuildField("X:", actionParams, actionFieldA, true); if (changeX) { GetFloatField.BuildFieldA("", actionParams, actionFieldB); } bool changeY = GetBoolValue.BuildField("Y:", actionParams, actionFieldC, true); if (changeY) { GetFloatField.BuildFieldA("", actionParams, actionFieldD); } bool changeZ = GetBoolValue.BuildField("Z:", actionParams, actionFieldE, true); if (changeZ) { GetFloatField.BuildFieldA("", actionParams, actionFieldF); } }
/// <summary> /// A slider (float values). /// </summary> /// <param name="title">Title for action field.</param> /// <param name="actionParams">Action field parameters.</param> /// <param name="actionField">Action field.</param> /// <param name="min">Smallest value for the slider.</param> /// <param name="max">Largest value for the slider.</param> /// <param name="titleToLeft">Show the title on the left?</param> public static void BuildFieldA(string title, HeroActionParams actionParams, HeroActionField actionField, int min = 0, int max = 100, bool titleToLeft = false) { SliderData slider = new SliderData(); slider.useSlider = true; slider.min = min; slider.max = max; GetFloatField.BuildFieldA(title, actionParams, actionField, titleToLeft, slider); }
// -------------------------------------------------------------- // Helpers // -------------------------------------------------------------- /// <summary> /// Get a value from a hero object list and set this value for a field in a script. /// </summary> /// <param name="field">The field to set.</param> /// <param name="actionParams">Action field parameters.</param> /// <param name="actionFieldB">Action field.</param> private static void SetFieldOnScript(FieldInfo field, HeroActionParams actionParams, HeroActionField actionFieldB) { // Get value on the target instance. object value = field.FieldType; // Test value type. if (value == typeof(int)) { GetIntegerField.BuildFieldA(field.Name + " (Int): ", actionParams, actionFieldB); } else if (value == typeof(float)) { GetFloatField.BuildFieldA(field.Name + " (Float): ", actionParams, actionFieldB); } else if (value == typeof(string)) { GetStringField.BuildFieldA(field.Name + " (String): ", actionParams, actionFieldB); } else if (value == typeof(bool)) { GetBoolField.BuildFieldA(field.Name + " (Bool): ", actionParams, actionFieldB); } else if (value == typeof(HeroKitObject)) { GetHeroObjectField.BuildFieldA(field.Name + " (HeroObject): ", actionParams, actionFieldB); } else if (value == typeof(GameObject)) { GetGameObjectField.BuildFieldA(field.Name + " (GameObject): ", actionParams, actionFieldB); } else { string valueType = value.ToString(); int index = valueType.LastIndexOf('.'); if (valueType.Length >= 2) { valueType = valueType.Substring(index + 1, valueType.Length - index - 1); } SimpleLayout.Label(valueType + " " + field.Name + ": [Value can't be stored by HeroKit]"); } }
/// <summary> /// Create a field in the hero kit editor for a parameter. /// </summary> /// <param name="param">The parameter.</param> /// <param name="actionParams">Action field parameters.</param> /// <param name="actionFieldB">Action field.</param> /// <param name="setHeroValue">True=user can set a value on a hero object. False=user can set a value in a script.</param> private static void GetParameter(ParameterInfo param, HeroActionParams actionParams, HeroActionField actionFieldB, bool setHeroValue) { // Get value on the target instance. object value = param.ParameterType; // Test value type. if (value == typeof(int)) { if (!setHeroValue) { GetIntegerField.BuildFieldA(param.Name + " (Int): ", actionParams, actionFieldB); } else { GetIntegerField.BuildFieldB(param.Name + " (Int): ", actionParams, actionFieldB); } } else if (value == typeof(float)) { if (!setHeroValue) { GetFloatField.BuildFieldA(param.Name + " (Float): ", actionParams, actionFieldB); } else { GetFloatField.BuildFieldB(param.Name + " (Float): ", actionParams, actionFieldB); } } else if (value == typeof(string)) { if (!setHeroValue) { GetStringField.BuildFieldA(param.Name + " (String): ", actionParams, actionFieldB, false, false, -10); } else { GetStringField.BuildFieldB(param.Name + " (String): ", actionParams, actionFieldB); } } else if (value == typeof(bool)) { if (!setHeroValue) { GetBoolField.BuildFieldA(param.Name + " (Bool): ", actionParams, actionFieldB); } else { GetBoolField.BuildFieldB(param.Name + " (Bool): ", actionParams, actionFieldB); } } else if (value == typeof(HeroKitObject)) { if (!setHeroValue) { GetHeroObjectField.BuildFieldA(param.Name + " (HeroObject): ", actionParams, actionFieldB); } else { GetHeroObjectField.BuildFieldB(param.Name + " (HeroObject): ", actionParams, actionFieldB); } } else if (value == typeof(GameObject)) { if (!setHeroValue) { GetGameObjectField.BuildFieldA(param.Name + " (GameObject): ", actionParams, actionFieldB); } else { GetGameObjectField.BuildFieldB(param.Name + " (GameObject): ", actionParams, actionFieldB); } } else { string valueType = value.ToString(); int index = valueType.LastIndexOf('.'); if (valueType.Length >= 2) { valueType = valueType.Substring(index + 1, valueType.Length - index - 1); } SimpleLayout.Label(valueType + " " + param.Name + ": [Value can't be stored by HeroKit]"); } }