/// <summary> /// 通过名称获取Float参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public float GetFloatParameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName, MainParameter.ParameterType.Float); return((mainParameter != null) ? mainParameter.FloatValue : 0f); }
/// <summary> /// 通过名称获取String参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public string GetStringParameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName, MainParameter.ParameterType.String); return((mainParameter != null) ? mainParameter.StringValue : ""); }
/// <summary> /// 通过名称获取Integer参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public int GetIntegerParameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName, MainParameter.ParameterType.Integer); return((mainParameter != null) ? mainParameter.IntegerValue : 0); }
/// <summary> /// 通过名称获取Material参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public Material GetMaterialParameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName); return((mainParameter != null) ? mainParameter.MaterialValue : null); }
/// <summary> /// 是否存在指定名称的参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>是否存在</returns> public bool IsExistParameter(string parameterName) { MainParameter mainParameter = MainParameters.Find((p) => { return(p.Name == parameterName); }); return(mainParameter != null); }
/// <summary> /// 通过名称获取Texture参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public Texture GetTextureParameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName); return((mainParameter != null) ? mainParameter.TextureValue : null); }
/// <summary> /// 通过名称获取AudioClip参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public AudioClip GetAudioClipParameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName); return((mainParameter != null) ? mainParameter.AudioClipValue : null); }
/// <summary> /// 通过名称获取DataSet参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public DataSetBase GetDataSetParameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName); return((mainParameter != null) ? mainParameter.DataSet : null); }
/// <summary> /// 通过名称获取Prefab参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public GameObject GetPrefabParameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName); return((mainParameter != null) ? mainParameter.PrefabValue : null); }
/// <summary> /// 通过名称获取Color参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public Color GetColorParameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName); return((mainParameter != null) ? mainParameter.ColorValue : Color.white); }
/// <summary> /// 通过名称获取Vector3参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public Vector3 GetVector3Parameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName); return((mainParameter != null) ? mainParameter.Vector3Value : Vector3.zero); }
/// <summary> /// 通过名称获取Boolean参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public bool GetBooleanParameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName); return((mainParameter != null) ? mainParameter.BooleanValue : false); }
/// <summary> /// 通过名称获取Vector2参数 /// </summary> /// <param name="parameterName">参数名称</param> /// <returns>参数</returns> public Vector2 GetVector2Parameter(string parameterName) { MainParameter mainParameter = GetParameter(parameterName, MainParameter.ParameterType.Vector2); return((mainParameter != null) ? mainParameter.Vector2Value : Vector2.zero); }
private void ParameterGUI() { GUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); GUILayout.Space(10); _showParameter = EditorGUILayout.Foldout(_showParameter, "Parameter", true); GUILayout.EndHorizontal(); if (_showParameter) { for (int i = 0; i < Target.MainParameters.Count; i++) { MainParameter mainParameter = Target.MainParameters[i]; GUILayout.BeginVertical("HelpBox"); GUILayout.BeginHorizontal(); GUILayout.Label("Type", GUILayout.Width(40)); EnumPopup(mainParameter.Type, out mainParameter.Type, ""); GUI.backgroundColor = Color.red; if (GUILayout.Button("Delete", "Minibutton", GUILayout.Width(50))) { Undo.RecordObject(target, "Delete Main Parameter"); Target.MainParameters.RemoveAt(i); HasChanged(); continue; } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Name:", GUILayout.Width(40)); TextField(mainParameter.Name, out mainParameter.Name, ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Value:", GUILayout.Width(40)); switch (mainParameter.Type) { case MainParameter.ParameterType.String: TextField(mainParameter.StringValue, out mainParameter.StringValue, ""); break; case MainParameter.ParameterType.Integer: IntField(mainParameter.IntegerValue, out mainParameter.IntegerValue, ""); break; case MainParameter.ParameterType.Float: FloatField(mainParameter.FloatValue, out mainParameter.FloatValue, ""); break; case MainParameter.ParameterType.Boolean: Toggle(mainParameter.BooleanValue, out mainParameter.BooleanValue, ""); break; case MainParameter.ParameterType.Vector2: Vector2Field(mainParameter.Vector2Value, out mainParameter.Vector2Value, ""); break; case MainParameter.ParameterType.Vector3: Vector3Field(mainParameter.Vector3Value, out mainParameter.Vector3Value, ""); break; case MainParameter.ParameterType.Color: ColorField(mainParameter.ColorValue, out mainParameter.ColorValue, ""); break; case MainParameter.ParameterType.DataSet: ObjectField(mainParameter.DataSet, out mainParameter.DataSet, false, ""); break; case MainParameter.ParameterType.Prefab: ObjectField(mainParameter.PrefabValue, out mainParameter.PrefabValue, false, ""); break; case MainParameter.ParameterType.Texture: ObjectField(mainParameter.TextureValue, out mainParameter.TextureValue, false, ""); break; case MainParameter.ParameterType.AudioClip: ObjectField(mainParameter.AudioClipValue, out mainParameter.AudioClipValue, false, ""); break; case MainParameter.ParameterType.Material: ObjectField(mainParameter.MaterialValue, out mainParameter.MaterialValue, false, ""); break; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("New", "Minibutton")) { Undo.RecordObject(target, "New Main Parameter"); Target.MainParameters.Add(new MainParameter()); HasChanged(); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }