当前位置: 首页>>代码示例>>C#>>正文


C# Material.GetColor方法代码示例

本文整理汇总了C#中UnityEngine.Material.GetColor方法的典型用法代码示例。如果您正苦于以下问题:C# Material.GetColor方法的具体用法?C# Material.GetColor怎么用?C# Material.GetColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Material的用法示例。


在下文中一共展示了Material.GetColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckMaterial

		public static string CheckMaterial(Material mat, BuildTarget buildTarget)
		{
			if (mat == null || mat.shader == null)
			{
				return null;
			}
			string shaderName = mat.shader.name;
			int lOD = ShaderUtil.GetLOD(mat.shader);
			bool flag = Array.Exists<string>(PerformanceChecks.kShadersWithMobileVariants, (string s) => s == shaderName);
			bool flag2 = PerformanceChecks.IsMobileBuildTarget(buildTarget);
			if (buildTarget == BuildTarget.Android && ShaderUtil.HasClip(mat.shader))
			{
				return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderWithClipAndroid", new object[0]);
			}
			if (!(mat.GetTag("PerformanceChecks", true).ToLower() == "false"))
			{
				if (flag)
				{
					if (flag2 && mat.HasProperty("_Color") && mat.GetColor("_Color") == new Color(1f, 1f, 1f, 1f))
					{
						return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderUsesWhiteColor", new object[]
						{
							"Mobile/" + shaderName
						});
					}
					if (flag2 && shaderName.StartsWith("Particles/"))
					{
						return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderHasMobileVariant", new object[]
						{
							"Mobile/" + shaderName
						});
					}
					if (shaderName == "RenderFX/Skybox" && mat.HasProperty("_Tint") && mat.GetColor("_Tint") == new Color(0.5f, 0.5f, 0.5f, 0.5f))
					{
						return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderMobileSkybox", new object[]
						{
							"Mobile/Skybox"
						});
					}
				}
				if (lOD >= 300 && flag2 && !shaderName.StartsWith("Mobile/"))
				{
					return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderExpensive", new object[0]);
				}
				if (shaderName.Contains("VertexLit") && mat.HasProperty("_Emission"))
				{
					Color color = mat.GetColor("_Emission");
					if (color.r >= 0.5f && color.g >= 0.5f && color.b >= 0.5f)
					{
						return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderUseUnlit", new object[0]);
					}
				}
				if (mat.HasProperty("_BumpMap") && mat.GetTexture("_BumpMap") == null)
				{
					return PerformanceChecks.FormattedTextContent("PerformanceChecks.ShaderNoNormalMap", new object[0]);
				}
			}
			return null;
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:59,代码来源:PerformanceChecks.cs

示例2: AssignNewShaderToMaterial

 public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
 {
     if (material.HasProperty("_Emission"))
     {
         material.SetColor("_EmissionColor", material.GetColor("_Emission"));
     }
     base.AssignNewShaderToMaterial(material, oldShader, newShader);
     if ((oldShader == null) || !oldShader.name.Contains("Legacy Shaders/"))
     {
         SetupMaterialWithBlendMode(material, (BlendMode) ((int) material.GetFloat("_Mode")));
     }
     else
     {
         BlendMode opaque = BlendMode.Opaque;
         if (oldShader.name.Contains("/Transparent/Cutout/"))
         {
             opaque = BlendMode.Cutout;
         }
         else if (oldShader.name.Contains("/Transparent/"))
         {
             opaque = BlendMode.Fade;
         }
         material.SetFloat("_Mode", (float) opaque);
         Material[] mats = new Material[] { material };
         this.DetermineWorkflow(MaterialEditor.GetMaterialProperties(mats));
         MaterialChanged(material, this.m_WorkflowMode);
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:28,代码来源:StandardShaderGUI.cs

示例3: Start

    void Start()
    {
        material = GetComponent<ParticleSystem> ().renderer.material;
        tintColor = material.GetColor("_TintColor");

        step = (targetAlpha / 255 - tintColor.a) / time;
    }
开发者ID:vinicz,项目名称:potential-octo-adventure,代码行数:7,代码来源:SmokeStormIncrease.cs

示例4: Grow

        IEnumerator Grow()
        {
            float f = 0;
            float t = 0;
            Vector3 originalScale = transform.localScale;
            Vector3 targetScale = originalScale * EndScale;
            Material originalMaterial = new Material(renderer.material);
            Color originalColor = originalMaterial.GetColor("_TintColor");
            Color targetColor = new Color(originalColor.r, originalColor.g, originalColor.b, 0F);
            renderer.material = originalMaterial;

            while (f <= duration)
            {
                t = f / duration;
                transform.localScale = Vector3.Lerp(originalScale, targetScale, t);

                originalMaterial.SetColor("_TintColor", Color.Lerp(originalColor, targetColor, t));

                f += Time.deltaTime;
                yield return new WaitForEndOfFrame();
            }

            if (mode == FXmode.DestroyAtEnd)
                Destroy(gameObject);

            else if (mode == FXmode.Loop)
                Play();
        }
开发者ID:Groutcho,项目名称:EventHorizon,代码行数:28,代码来源:Shockwave.cs

示例5: FromMaterial

        public static SMaterial FromMaterial(Material mat)
        {
            if (mat == null)
                return null;

            Shader shader = mat.shader;
            if (shader == null)
                return null;

            SMaterial result = new SMaterial();
            result.instanceID = mat.GetInstanceID();
            result.materialName = mat.name;
            result.shaderName = shader.name;

            ShaderProperties.Info info = ShaderPropertyHelper.GetShaderInfo(shader.name);

            if (info != null){
                ComposedByteStream rawData = new ComposedByteStream();

                int iMax = info.propertyNames.Length;
                for (int i = 0; i < iMax; i++)
                {
                    string propName = info.propertyNames[i];
                    switch (info.propertyTypes[i])
                    {
                        case ShaderProperties.PropType.Color:
                            Color color = mat.GetColor(propName);
                            rawData.AddStream(new float[] { color.r, color.g, color.b, color.a });
                            break;

                        case ShaderProperties.PropType.Range:
                        case ShaderProperties.PropType.Float:
                            rawData.AddStream(new float[] { mat.GetFloat(propName) });
                            break;

                        case ShaderProperties.PropType.TexEnv:
                            Texture texture = mat.GetTexture(propName);
                            Vector2 offset = mat.GetTextureOffset(propName);
                            Vector2 scale = mat.GetTextureScale(propName);

                            rawData.AddStream(new int[] { texture != null ? texture.GetInstanceID() : -1 });
                            rawData.AddStream(texture != null ? texture.name : "" );
                            rawData.AddStream(new float[] { offset.x, offset.y });
                            rawData.AddStream(new float[] { scale.x, scale.y });
                            break;

                        case ShaderProperties.PropType.Vector:
                            Vector4 vector = mat.GetVector(propName);
                            rawData.AddStream(new float[] { vector.x, vector.y, vector.z, vector.w });
                            break;
                    }
                }
                result.rawData = rawData.Compose();
                return result;
            } else {
                if (vBug.settings.general.debugMode)
                    Debug.LogError("No shader-info found @" + shader.name);
                return null;
            }
        }
开发者ID:WhiteRavensGame,项目名称:JRPGTownPrototype,代码行数:60,代码来源:MaterialSerializeHelper.cs

示例6: Start

 void Start()
 {
     colorSmooth = Random.Range(smooth.min, smooth.max);
     _colorSmooth = colorSmooth;
     mat = GetComponent<Renderer>().materials[materialIndex];
     toColor = mat.GetColor("_EmissionColor");
 }
开发者ID:coderDarren,项目名称:TheArchitect,代码行数:7,代码来源:ColorOvertime.cs

示例7: CopyMaterialProperties

        /// <summary>
        /// Copy Shader properties from source to destination material.
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static void CopyMaterialProperties(Material source, Material destination)
        {
            MaterialProperty[] source_prop = MaterialEditor.GetMaterialProperties(new Material[] { source });

            for (int i = 0; i < source_prop.Length; i++)
            {
                int property_ID = Shader.PropertyToID(source_prop[i].name);
                if (destination.HasProperty(property_ID))
                {
                    //Debug.Log(source_prop[i].name + "  Type:" + ShaderUtil.GetPropertyType(source.shader, i));
                    switch (ShaderUtil.GetPropertyType(source.shader, i))
                    {
                        case ShaderUtil.ShaderPropertyType.Color:
                            destination.SetColor(property_ID, source.GetColor(property_ID));                          
                            break;
                        case ShaderUtil.ShaderPropertyType.Float:
                            destination.SetFloat(property_ID, source.GetFloat(property_ID));
                            break;
                        case ShaderUtil.ShaderPropertyType.Range:
                            destination.SetFloat(property_ID, source.GetFloat(property_ID));
                            break;
                        case ShaderUtil.ShaderPropertyType.TexEnv:
                            destination.SetTexture(property_ID, source.GetTexture(property_ID));
                            break;
                        case ShaderUtil.ShaderPropertyType.Vector:
                            destination.SetVector(property_ID, source.GetVector(property_ID));
                            break;
                    }
                }
            }

        }
开发者ID:koko11,项目名称:MatrixVR,代码行数:37,代码来源:TMPro_EditorShaderUtilities.cs

示例8: GetValues

	public List<StoredValue> GetValues(Material m)
	{
		var list = GetShaderProperties(m);
		var output = new List<StoredValue>();
		foreach(var p in list)
		{
			var o = new StoredValue { Property = p };
			output.Add(o);
			switch(p.type)
			{
			case MaterialProperty.PropertyType.color:
				o.Value = m.GetColor(p.name);
				break;
			case MaterialProperty.PropertyType.real:
				o.Value = m.GetFloat(p.name);
				break;
			case MaterialProperty.PropertyType.texture:
				o.Value = m.GetTexture(p.name);
				break;
			case MaterialProperty.PropertyType.vector:
				o.Value = m.GetVector(p.name);
				break;
			case MaterialProperty.PropertyType.textureOffset:
				o.Value = m.GetTextureOffset(p.name);
				break;
			case MaterialProperty.PropertyType.textureScale:
				o.Value = m.GetTextureScale(p.name);
				break;
			case MaterialProperty.PropertyType.matrix:
				o.Value = m.GetMatrix(p.name);
				break;
			}
		}
		return output;
	}
开发者ID:MHaubenstock,项目名称:RPG-Board-3D,代码行数:35,代码来源:StoreMaterials.cs

示例9: SetMaterialKeywords

		public static void SetMaterialKeywords(Material material, WorkflowMode workflowMode)
		{
			// Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
			// (MaterialProperty value might come from renderer material property block)
			SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap"));
			if (workflowMode == WorkflowMode.Specular && material.HasProperty("_SpecGlossMap"))
				SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap"));
			else if (workflowMode == WorkflowMode.Metallic && material.HasProperty("_MetallicGlossMap"))
				SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap"));
			SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap"));
			SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap"));

			bool shouldEmissionBeEnabled = ShouldEmissionBeEnabled(material.GetColor("_EmissionColor"));
			SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled);

			// Setup lightmap emissive flags
			MaterialGlobalIlluminationFlags flags = material.globalIlluminationFlags;
			if ((flags & (MaterialGlobalIlluminationFlags.BakedEmissive | MaterialGlobalIlluminationFlags.RealtimeEmissive)) != 0)
			{
				flags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
				if (!shouldEmissionBeEnabled)
					flags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;

				material.globalIlluminationFlags = flags;
			}

			SetKeyword(material, "_VERTEXCOLOR", material.GetFloat("_IntensityVC") > 0f);
		}
开发者ID:RCBiczok,项目名称:ParaUnity,代码行数:28,代码来源:UnityVC.cs

示例10: _GetColor

    private static float _GetColor(Material obj, MaterialPropertyType pType, string paramName)
    {
        Color c;

        if(paramName == null || paramName.Length == 0) {
            c = obj.color;
        } else {
            c = obj.GetColor(paramName);
        }

        switch(pType) {
        case MaterialPropertyType.Color_R:
            return c.r;
        case MaterialPropertyType.Color_G:
            return c.g;
        case MaterialPropertyType.Color_B:
            return c.b;
        case MaterialPropertyType.Color_RGB:
            return c.r;
        case MaterialPropertyType.Color_A:
            return c.a;
        case MaterialPropertyType.Color_R_Relative:
            return c.r;
        case MaterialPropertyType.Color_G_Relative:
            return c.g;
        case MaterialPropertyType.Color_B_Relative:
            return c.b;
        case MaterialPropertyType.Color_RGB_Relative:
            return c.r;
        case MaterialPropertyType.Color_A_Relative:
            return c.a;
        }

        return 0.0f;
    }
开发者ID:8monolith8,项目名称:fuze-vj-kit,代码行数:35,代码来源:VJMaterialPropertyHelper.cs

示例11: Awake

	/// <summary>
	/// 
	/// </summary>
	void Awake()
	{

		m_Transform = transform;

		m_ForceShow = false;

		// if a light is present in the prefab we will cache and use it
		m_Light = GetComponent<Light>();
		if (m_Light != null)
		{
			m_LightIntensity = m_Light.intensity;
			m_Light.intensity = 0.0f;
		}

		m_Renderer = GetComponent<Renderer>();
		if (m_Renderer != null)
		{
			m_Material = GetComponent<Renderer>().material;
			if (m_Material != null)
			{
				// the muzzleflash is meant to use the 'Particles/Additive'
				// (unity default) shader which has the 'TintColor' property
				m_Color = m_Material.GetColor("_TintColor");
				m_Color.a = 0.0f;
			}
		}

	}
开发者ID:BHD7,项目名称:Ghost_Town_FPS_Zombies,代码行数:32,代码来源:vp_MuzzleFlash.cs

示例12: OnRecord

 public override void OnRecord()
 {
     if (_material = material)
     {
         _original = _material.GetColor(propertyID);
     }
 }
开发者ID:izaleu,项目名称:Steamplane,代码行数:7,代码来源:TweenMaterialColor.cs

示例13: SetFromToCurrent

 public void SetFromToCurrent()
 {
     if (_material = material)
     {
         from = _material.GetColor(propertyID);
     }
 }
开发者ID:izaleu,项目名称:Steamplane,代码行数:7,代码来源:TweenMaterialColor.cs

示例14: Awake

 // Use this for initialization
 void Awake()
 {
     colorRenderer = GetComponent<Renderer>();
     mat = colorRenderer.material;
     originalColor = mat.GetColor("_EmissionColor");
     baseColor = originalColor;
 }
开发者ID:hackerspace-ntnu,项目名称:hac-man,代码行数:8,代码来源:EmissionController.cs

示例15: Init

 public void Init(TurnBasedUnit parentShip)
 {
     trans = transform;
     shieldMat = renderer.material;
     originalColour = shieldMat.GetColor("_Color");
     ParentShip = parentShip;
 }
开发者ID:HaKDMoDz,项目名称:Capstone_Space_Game,代码行数:7,代码来源:ShipShield.cs


注:本文中的UnityEngine.Material.GetColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。