Beispiel #1
0
 private void OnPropertyContextMenu(GenericMenu menu, MaterialProperty property, Renderer[] renderers)
 {
     if (this.m_Responder != null)
     {
         if (property.targets != null && property.targets.Length != 0)
         {
             if (renderers != null && renderers.Length != 0)
             {
                 List <PropertyModification> list = new List <PropertyModification>();
                 for (int i = 0; i < renderers.Length; i++)
                 {
                     Renderer target = renderers[i];
                     list.AddRange(MaterialAnimationUtility.MaterialPropertyToPropertyModifications(property, target));
                 }
                 if (this.m_Responder.IsEditable(renderers[0]))
                 {
                     this.OnPropertyContextMenu(menu, list.ToArray());
                 }
                 else
                 {
                     this.OnDisabledPropertyContextMenu(menu);
                 }
             }
         }
     }
 }
Beispiel #2
0
        public static PropertyModification[] MaterialPropertyToPropertyModifications(MaterialProperty materialProp, Renderer target)
        {
            PropertyModification[] result;
            switch (materialProp.type)
            {
            case MaterialProperty.PropType.Color:
                result = MaterialAnimationUtility.MaterialPropertyToPropertyModifications(materialProp, target, materialProp.colorValue);
                break;

            case MaterialProperty.PropType.Vector:
                result = MaterialAnimationUtility.MaterialPropertyToPropertyModifications(materialProp, target, materialProp.vectorValue);
                break;

            case MaterialProperty.PropType.Float:
            case MaterialProperty.PropType.Range:
                result = MaterialAnimationUtility.MaterialPropertyToPropertyModifications(materialProp, target, materialProp.floatValue);
                break;

            case MaterialProperty.PropType.Texture:
            {
                string name = materialProp.name + "_ST";
                result = MaterialAnimationUtility.MaterialPropertyToPropertyModifications(name, target, materialProp.vectorValue);
                break;
            }

            default:
                result = null;
                break;
            }
            return(result);
        }
        void OnPropertyContextMenu(GenericMenu menu, MaterialProperty property, Renderer[] renderers)
        {
            if (m_Responder == null)
            {
                return;
            }

            if (property.targets == null || property.targets.Length == 0)
            {
                return;
            }

            if (renderers == null || renderers.Length == 0)
            {
                return;
            }

            var modifications = new List <PropertyModification>();

            foreach (Renderer renderer in renderers)
            {
                modifications.AddRange(MaterialAnimationUtility.MaterialPropertyToPropertyModifications(property, renderer));
            }

            if (m_Responder.IsEditable(renderers[0]))
            {
                OnPropertyContextMenu(menu, modifications.ToArray());
            }
            else
            {
                OnDisabledPropertyContextMenu(menu);
            }
        }
Beispiel #4
0
        public static bool ApplyMaterialModificationToAnimationRecording(MaterialProperty materialProp, int changedMask, Renderer target, object oldValue)
        {
            bool result;

            switch (materialProp.type)
            {
            case MaterialProperty.PropType.Color:
            {
                MaterialAnimationUtility.SetupMaterialPropertyBlock(materialProp, changedMask, target);
                bool flag = MaterialAnimationUtility.ApplyMaterialModificationToAnimationRecording(MaterialAnimationUtility.MaterialPropertyToPropertyModifications(materialProp, target, (Color)oldValue));
                if (!flag)
                {
                    MaterialAnimationUtility.TearDownMaterialPropertyBlock(target);
                }
                result = flag;
                break;
            }

            case MaterialProperty.PropType.Vector:
            {
                MaterialAnimationUtility.SetupMaterialPropertyBlock(materialProp, changedMask, target);
                bool flag = MaterialAnimationUtility.ApplyMaterialModificationToAnimationRecording(MaterialAnimationUtility.MaterialPropertyToPropertyModifications(materialProp, target, (Vector4)oldValue));
                if (!flag)
                {
                    MaterialAnimationUtility.TearDownMaterialPropertyBlock(target);
                }
                result = flag;
                break;
            }

            case MaterialProperty.PropType.Float:
            case MaterialProperty.PropType.Range:
            {
                MaterialAnimationUtility.SetupMaterialPropertyBlock(materialProp, changedMask, target);
                bool flag = MaterialAnimationUtility.ApplyMaterialModificationToAnimationRecording(MaterialAnimationUtility.MaterialPropertyToPropertyModifications(materialProp, target, (float)oldValue));
                if (!flag)
                {
                    MaterialAnimationUtility.TearDownMaterialPropertyBlock(target);
                }
                result = flag;
                break;
            }

            case MaterialProperty.PropType.Texture:
                if (MaterialProperty.IsTextureOffsetAndScaleChangedMask(changedMask))
                {
                    string name = materialProp.name + "_ST";
                    MaterialAnimationUtility.SetupMaterialPropertyBlock(materialProp, changedMask, target);
                    bool flag = MaterialAnimationUtility.ApplyMaterialModificationToAnimationRecording(MaterialAnimationUtility.MaterialPropertyToPropertyModifications(name, target, (Vector4)oldValue));
                    if (!flag)
                    {
                        MaterialAnimationUtility.TearDownMaterialPropertyBlock(target);
                    }
                    result = flag;
                }
                else
                {
                    result = false;
                }
                break;

            default:
                result = false;
                break;
            }
            return(result);
        }