public void AssignFrom(OverlayColorData src) { if (src.name != null) { name = String.Copy(src.name); } EnsureChannels(src.channelMask.Length); for (int i = 0; i < src.channelMask.Length; i++) { channelMask[i] = src.channelMask[i]; } for (int i = 0; i < src.channelAdditiveMask.Length; i++) { channelAdditiveMask[i] = src.channelAdditiveMask[i]; } PropertyBlock = new UMAMaterialPropertyBlock(); if (src.PropertyBlock != null) { PropertyBlock.shaderProperties = new List <UMAProperty>(src.PropertyBlock.shaderProperties.Count); for (int i = 0; i < src.PropertyBlock.shaderProperties.Count; i++) { UMAProperty up = src.PropertyBlock.shaderProperties[i]; PropertyBlock.shaderProperties.Add(up.Clone()); } } }
/// <summary> /// Make sure the class is initialized /// </summary> public static void CheckInitialize() { if (PropertyTypeStrings.Length == 0) { availableTypes = UMAMaterialPropertyBlock.GetPropertyTypes(); PropertyTypeStrings = availableTypes.Select(i => i.ToString()).ToArray(); } }
/// <summary> /// Performs editing on a UMAMaterialPropertyBlock. Returns true if changed, false if not changed /// </summary> /// <param name="umpb">UMAMaterialPropertyBlock</param> /// <returns></returns> public static bool OnGUI(UMAMaterialPropertyBlock umpb) { UMAMaterialPropertyBlock.CheckInitialize(); GUILayout.Space(5); bool changed = false; EditorGUI.BeginChangeCheck(); GUIHelper.BeginVerticalPadded(5, new Color(0.65f, 0.675f, 1f)); GUILayout.Label("Shader Properties"); GUILayout.BeginHorizontal(); TypeIndex = EditorGUILayout.Popup(TypeIndex, UMAMaterialPropertyBlock.PropertyTypeStrings); if (GUILayout.Button("Add Type")) { umpb.AddProperty(UMAMaterialPropertyBlock.availableTypes[TypeIndex], UMAMaterialPropertyBlock.PropertyTypeStrings[TypeIndex]); } GUILayout.EndHorizontal(); bool dark = false; UMAProperty delme = null; if (umpb.shaderProperties != null) { foreach (UMAProperty up in umpb.shaderProperties) { if (up == null) { continue; } GUIHelper.BeginVerticalIndented(3, new Color(0.75f, 0.75f, 1f)); if (dark) { GUIHelper.BeginVerticalPadded(5, new Color(0.85f, 0.85f, 1f)); dark = false; } else { GUIHelper.BeginVerticalPadded(5, new Color(0.65f, 0.65f, 0.9f)); dark = true; } if (up.OnGUI()) { delme = up; } GUIHelper.EndVerticalPadded(5); GUIHelper.EndVerticalIndented(); } if (delme != null) { umpb.shaderProperties.Remove(delme); } } GUIHelper.EndVerticalPadded(5); GUILayout.Space(5); changed = EditorGUI.EndChangeCheck(); return(changed); }