public override int GetHashCode() { return(MaterialReference.GetHashCode()); }
/** * Draw Inspector GUI for this AssetGenerator. */ public void OnInspectorGUI(Action onValueChanged) { if (m_referenceMat == null) { m_referenceMat = new MaterialReference(); onValueChanged(); } if (m_properties == null) { m_properties = new List <PropertyField>(); onValueChanged(); } #if !UNITY_2018_1_OR_NEWER if (m_hdrConfig == null) { m_hdrConfig = new ColorPickerHDRConfig(0f, 10f, 0f, 10f); } #endif var refMat = (Material)EditorGUILayout.ObjectField("Reference Material", m_referenceMat.Object, typeof(Material), false); if (refMat != m_referenceMat.Object) { m_referenceMat.Object = refMat; onValueChanged(); } var newFieldName = EditorGUILayout.TextField("Property Name", m_propertyName); if (newFieldName != m_propertyName) { m_propertyName = newFieldName; onValueChanged(); } GUILayout.Space(8f); PropertyField removing = null; foreach (var p in m_properties) { DrawPropertyGUI(p, onValueChanged, ref removing); GUILayout.Space(8f); } if (removing != null) { m_properties.Remove(removing); onValueChanged(); } GUILayout.Space(8f); using (new GUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button("+", GUILayout.Width(20f))) { var menu = new GenericMenu(); foreach (var v in (PropertyType[])Enum.GetValues(typeof(PropertyType))) { var propertyType = v; menu.AddItem(new GUIContent(v.ToString()), false, () => { m_properties.Add(new PropertyField(propertyType)); onValueChanged(); }); } menu.ShowAsContext(); } } }
/** * Draw Inspector GUI for this AssetGenerator. */ public void OnInspectorGUI(Action onValueChanged) { if (m_referenceMat == null) { m_referenceMat = new MaterialReference(); onValueChanged(); } if (m_properties == null) { m_properties = new List <PropertyField> (); onValueChanged(); } var refMat = (Material)EditorGUILayout.ObjectField("Reference Material", m_referenceMat.Object, typeof(Material), false); if (refMat != m_referenceMat.Object) { m_referenceMat.Object = refMat; onValueChanged(); } var newFieldName = EditorGUILayout.TextField("Property Name", m_propertyName); if (newFieldName != m_propertyName) { m_propertyName = newFieldName; onValueChanged(); } GUILayout.Space(8f); PropertyField removing = null; foreach (var p in m_properties) { var t = (Texture)EditorGUILayout.ObjectField("Texture", p.texture.Object, typeof(Texture2D), false); if (t != p.texture.Object) { p.texture.Object = t; onValueChanged(); } using (new GUILayout.HorizontalScope()) { var n = EditorGUILayout.TextField("Property Name", p.propertyName); if (n != p.propertyName) { p.propertyName = n; onValueChanged(); } if (GUILayout.Button("-", GUILayout.Width(20f))) { removing = p; } } } if (GUILayout.Button("Add Property")) { m_properties.Add(new PropertyField()); onValueChanged(); } if (removing != null) { m_properties.Remove(removing); onValueChanged(); } }