Example #1
0
        /// <summary>
        /// Deep copy of the OverlayColorData.
        /// </summary>
        public OverlayColorData Duplicate()
        {
            var res = new OverlayColorData();

            res.name = name;

            res.channelMask = new Color[channelMask.Length];
            for (int i = 0; i < channelMask.Length; i++)
            {
                res.channelMask[i] = channelMask[i];
            }
            res.channelAdditiveMask = new Color[channelAdditiveMask.Length];
            for (int i = 0; i < channelAdditiveMask.Length; i++)
            {
                res.channelAdditiveMask[i] = channelAdditiveMask[i];
            }
            if (PropertyBlock != null)
            {
                res.PropertyBlock = new UMAMaterialPropertyBlock();
                res.PropertyBlock.shaderProperties = new List <UMAProperty>(PropertyBlock.shaderProperties.Count);
                for (int i = 0; i < PropertyBlock.shaderProperties.Count; i++)
                {
                    UMAProperty up = PropertyBlock.shaderProperties[i];
                    if (up != null)
                    {
                        res.PropertyBlock.shaderProperties.Add(up.Clone());
                    }
                }
            }
            return(res);
        }
Example #2
0
        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());
                }
            }
        }
Example #3
0
        public UMAProperty AddProperty <t>(string propertyName)
        {
            UMAProperty prop = Activator.CreateInstance <t>() as UMAProperty;

            prop.name = propertyName;
            AddProperty(prop);
            return(prop);
        }
Example #4
0
        public UMAProperty AddProperty(Type propertyType, string propertyName)
        {
            UMAProperty prop = Activator.CreateInstance(propertyType) as UMAProperty;

            prop.name = propertyName;
            AddProperty(prop);
            return(prop);
        }
Example #5
0
        public void AddProperty(UMAProperty property)
        {
            if (shaderProperties == null)
            {
                shaderProperties = new List <UMAProperty>();
            }

            shaderProperties.Add(property);
        }
Example #6
0
 public PropertyHolder(UMAProperty prop)
 {
     property = prop;
 }
Example #7
0
        /// <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);
        }