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


C# Material.SetTexture方法代码示例

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


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

示例1: SetNewMaterial

    public void SetNewMaterial()
    {
        Renderer _renderer = GetComponent<Renderer>();
        Material newMat = new Material(Shader.Find("Diffuse"));
        //Material newMat = new Material(renderer.sharedMaterial);

        bool baseMaterialHaveNormalMap = _renderer.sharedMaterial.GetTexture("_BumpMap");
        bool baseMaterialHaveCubeMap = _renderer.sharedMaterial.GetTexture("_Cube");

        newMat.SetTexture("_MainTex", _renderer.sharedMaterial.GetTexture("_MainTex"));
        newMat.SetTextureOffset("_MainTex", offset);
        newMat.SetTextureScale("_MainTex", scale);

        if (baseMaterialHaveNormalMap)
        {
            newMat.SetTexture("_BumpMap", _renderer.sharedMaterial.GetTexture("_BumpMap"));
            newMat.SetTextureOffset("_BumpMap", offset);
            newMat.SetTextureScale("_BumpMap", scale);
        }
        if (baseMaterialHaveCubeMap)
        {
            newMat.SetTexture("_Cube", _renderer.sharedMaterial.GetTexture("_Cube"));
            newMat.SetTextureScale("_Cube", scale);
            newMat.SetTextureOffset("_Cube", offset);
        }

        newMat.color = materialColor;

        _renderer.sharedMaterial = newMat;
    }
开发者ID:FrenchKrab,项目名称:aottg-assetbundleimporter,代码行数:30,代码来源:MaterialEditor.cs

示例2: AddOverlay

        private void AddOverlay(TextureSet mTexture, TextureSet dTexture, float altitude, float fadeDistance, float pqsfadeDistance)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            string[] resources = assembly.GetManifestResourceNames();

            StreamReader shaderStreamReader = new StreamReader(assembly.GetManifestResourceStream("CityLights.Shaders.Compiled-SphereCityLights.shader"));

            Log("read stream");
            String shaderString = shaderStreamReader.ReadToEnd();
            Material lightMaterial = new Material(shaderString);
            Material pqsLightMaterial = new Material(shaderString);

            lightMaterial.SetTexture("_MainTex", mTexture.Texture);
            lightMaterial.SetTexture("_DetailTex", dTexture.Texture);
            lightMaterial.SetFloat("_DetailScale", dTexture.Scale);
            lightMaterial.SetVector("_DetailOffset", dTexture.Offset);
            lightMaterial.SetFloat("_FadeDist", fadeDistance);
            lightMaterial.SetFloat("_FadeScale", 1);

            pqsLightMaterial.SetTexture("_MainTex", mTexture.Texture);
            pqsLightMaterial.SetTexture("_DetailTex", dTexture.Texture);
            pqsLightMaterial.SetFloat("_DetailScale", dTexture.Scale);
            pqsLightMaterial.SetVector("_DetailOffset", dTexture.Offset);
            pqsLightMaterial.SetFloat("_FadeDist", pqsfadeDistance);
            pqsLightMaterial.SetFloat("_FadeScale", .02f);

            overlayList.Add(Overlay.GeneratePlanetOverlay("Kerbin", altitude, lightMaterial, pqsLightMaterial, mTexture.StartOffset, false, true));
        }
开发者ID:TheTriGeo,项目名称:EnvironmentalVisualEnhancements,代码行数:28,代码来源:CityLights.cs

示例3: GenerateWireframeMeshsAndMaterials

	private void GenerateWireframeMeshsAndMaterials() {
		foreach (MeshNMaterial subObj in subObjects) {
			//添加AmazingWireframeGenerator
			subObj.gameObject.AddComponent<TheAmazingWireframeGenerator>();
			for (int i = 0;i < subObj.originalMaterials.Length;i++) {
				Material wireframeNoTexMat = new Material(
					Shader.Find("VacuumShaders/The Amazing Wireframe/Unlit/NoTex"));
				wireframeNoTexMat.SetColor("_Color", subObj.originalMaterials[i].GetColor("_Color"));
				wireframeNoTexMat.EnableKeyword("V_WIRE_ANTIALIASING_ON");
				wireframeNoTexMat.EnableKeyword("V_WIRE_LIGHT_ON");
				subObj.wireframeNoTexMaterials[i] = wireframeNoTexMat;
				Material wireframeTexMat = new Material(
						Shader.Find("VacuumShaders/The Amazing Wireframe/Deferred/Bumped Specular"));
				wireframeTexMat.SetColor("_Color", subObj.originalMaterials[i].GetColor("_Color"));
				if (subObj.originalMaterials[i].HasProperty("_SpecColor"))
					wireframeTexMat.SetColor("_SpecColor", subObj.originalMaterials[i].GetColor("_SpecColor"));
				if (subObj.originalMaterials[i].HasProperty("_Shininess"))
					wireframeTexMat.SetFloat("_Shininess", subObj.originalMaterials[i].GetFloat("_Shininess"));
				wireframeTexMat.SetTexture("_MainTex", subObj.originalMaterials[i].GetTexture("_MainTex"));
				if (subObj.originalMaterials[i].HasProperty("_BumpMap"))
					wireframeTexMat.SetTexture("_BumpMap", subObj.originalMaterials[i].GetTexture("_BumpMap"));
				wireframeTexMat.EnableKeyword("V_WIRE_ANTIALIASING_ON");
				wireframeTexMat.EnableKeyword("V_WIRE_LIGHT_ON");
				subObj.wireframeTexMaterials[i] = wireframeTexMat;
			}
		}
	}
开发者ID:AmaranthYan,项目名称:theArena,代码行数:27,代码来源:FocusableWeaponComponent.cs

示例4: OnAssignMaterialModel

    Material OnAssignMaterialModel( Material material, Renderer renderer )
    {
        //Debug.Log( "Looking for material for " + renderer.name );
        string standardMatPath = "Assets/Models/" + renderer.name + "/Materials/" + material.name + ".mat";
        string standardMatDir = "Assets/Models/" + renderer.name + "/Materials/";
        string standardDiffusePath = "Assets/Models/" + renderer.name + "/Textures/" + renderer.name + "_diffuse.png";
        string standardNormalPath = "Assets/Models/" + renderer.name + "/Textures/" + renderer.name + "_normal.png";

        if( AssetDatabase.LoadAssetAtPath( standardMatPath, typeof( Material ) ) ) {
            //Debug.Log( "Found standard material" );
            return ( Material )AssetDatabase.LoadAssetAtPath( standardMatPath, typeof( Material ) );
        } else {
            //Debug.Log( "Couldn't find standard material, creating new material in " + standardMatPath );
            material.shader = Shader.Find( "Diffuse" );

            if( AssetDatabase.LoadAssetAtPath( standardDiffusePath, typeof( Texture2D ) ) ) {
                //Debug.Log( "Found associated diffuse texture for " + material.name );
                Texture defaultDiffuse = ( Texture2D )AssetDatabase.LoadAssetAtPath( standardDiffusePath, typeof( Texture2D ) );
                material.SetTexture( "Base", defaultDiffuse );
            }

            if( AssetDatabase.LoadAssetAtPath( standardNormalPath, typeof( Texture ) ) ) {
                //Debug.Log( "Found associated normal texture for " + material.name );
                Texture2D defaultNormal = ( Texture2D )AssetDatabase.LoadAssetAtPath( standardNormalPath, typeof( Texture2D ) );
                material.shader = Shader.Find( "Bumped Diffuse" );
                material.SetTexture( "Normalmap", defaultNormal );
            }

            Directory.CreateDirectory( standardMatDir );
            AssetDatabase.CreateAsset( material, standardMatPath );
            return material;
        }
    }
开发者ID:CinnamonBagels,项目名称:project-eva,代码行数:33,代码来源:AssetPostProcessor.cs

示例5: InitMaterial

    void InitMaterial(Material mat)
    {
        mat.SetTexture("_Transmittance", m_transmittance);
        mat.SetTexture("_Inscatter", m_inscatter);

        mat.SetFloat("SUN_INTENSITY", m_sunIntensity);
        mat.SetVector("SUN_DIR", m_sun.transform.forward*-1.0f);

        //Dont change this
        mat.SetVector("EARTH_POS", new Vector3(0.0f, 6360010.0f, 0.0f));
    }
开发者ID:Togene,项目名称:BeCalm,代码行数:11,代码来源:Sky.cs

示例6: Start

 private void Start()
 {
     Debug.Assert(_chargeSpeed > 0f);
     Material mat = new Material(Shader.Find(_shaderName));
     _citizenBodyRenderer.material = mat;
     _currThres = _bottomThres;
     mat.SetVector("_PlanePos", new Vector4(_planeHeight, 0, 0, 1));
     mat.SetVector("_PlaneNormal", new Vector4(-1, 0, 0, 0));
     mat.SetFloat("_ThresDist", _currThres);
     mat.SetTexture("_BeforeTex", VFXManager.Instance.RandomRiotTex());
     mat.SetTexture("_AfterTex", _afterTex);
 }
开发者ID:MangoSister,项目名称:PunkRising,代码行数:12,代码来源:CitizenChargeFX.cs

示例7: getFoodMat

 public static Material getFoodMat(int num)
 {
     Material ret;
     bool success = dicFoodMats.TryGetValue (num,out ret);
     if (!success) {
         ret = new Material(Shader.Find("SnakeXShader/Food"));
         ret.SetTexture("_MainTex", ResourceControl.getInstance().getTexture("body" + num));
         ret.SetTexture("_BlendTex", ResourceControl.getInstance().getTexture("foodBlender"));
         dicFoodMats.Add(num,ret);
     }
     return ret;
 }
开发者ID:yizhengtutu,项目名称:snakeX,代码行数:12,代码来源:MatControl.cs

示例8: CreateMaterial

	public Material CreateMaterial( string strShaderName, Texture tex)
	{
		Shader shader = Get( strShaderName);
		Material mtrl = new Material( shader);
		
		if( strShaderName.Equals( "newark_shader"))
			mtrl.SetTexture( "_maintex", tex);
		else
			mtrl.SetTexture( "_MainTex", tex);
		
		return mtrl;
	}
开发者ID:ftcaicai,项目名称:ArkClient,代码行数:12,代码来源:AsShaderManager.cs

示例9: Start

        //        protected override void Start()
        public override void Start()
        {
            base.Start();

            m_initJacobiansMat=new Material(ShaderTool.GetMatFromShader2("CompiledInitJacobians.shader"));
            m_whiteCapsPrecomputeMat=new Material(ShaderTool.GetMatFromShader2("CompiledWhiteCapsPrecompute.shader"));

            m_initJacobiansMat.SetTexture("_Spectrum01", m_spectrum01);
            m_initJacobiansMat.SetTexture("_Spectrum23", m_spectrum23);
            m_initJacobiansMat.SetTexture("_WTable", m_WTable);
            m_initJacobiansMat.SetVector("_Offset", m_offset);
            m_initJacobiansMat.SetVector("_InverseGridSizes", m_inverseGridSizes);
        }
开发者ID:rbray89,项目名称:Scatterer,代码行数:14,代码来源:OceanWhiteCaps.cs

示例10: createMaterial2

        public static Material createMaterial2(string colorTexturePath, string normalTexturePath, string specularTexturePath)
        {
            WWW loader;
            Material mat = new Material(Shader.Find("Bumped Diffuse"));

            loader = new WWW("file://" + colorTexturePath);
            mat.SetTexture("_MainTex", loader.texture);

            loader = new WWW("file://" + normalTexturePath);
            Texture2D normalTexture = NormalMap(loader.texture);
            mat.SetTexture("_BumpMap", normalTexture);
            mat.SetFloat("_BumpScale", 1.0f);
            return mat;
        }
开发者ID:hybrid1969,项目名称:Polimi-OSM-City-Engine,代码行数:14,代码来源:InGameTextureHandler.cs

示例11: CreateUIAtlasPrefab

    private static void CreateUIAtlasPrefab(Object ob)
    {
        string path = AssetDatabase.GetAssetPath(ob);
        if (string.IsNullOrEmpty(path) || !IsTextureFile(path))
        {
            Debug.LogError("未选中对象或者选择的对象不是图片");
            return;
        }

        if (Path.GetExtension(path) == ".png" && !path.Contains("_Alpha") && !path.Contains("_RGB"))
        {
            ShowProgress(path, 0.5f);

            #region 第一步:根据图片创建材质对象
            Material mat = new Material(Shader.Find("UI/UI_ETC"));
            mat.name = ob.name;
            AssetDatabase.CreateAsset(mat, path.Replace(".png", ".mat"));
            SetTextureReadable(path);

            SeperateRGBandAlphaChannel(path);

            TextureSetting(path, TextureImporterType.Default, TextureImporterFormat.ETC_RGB4, false);
            Texture2D _mainTex = AssetDatabase.LoadAssetAtPath(path.Replace(".png", "_RGB.png"), typeof(Texture2D)) as Texture2D;
            Texture2D _alphaTex = AssetDatabase.LoadAssetAtPath(path.Replace(".png", "_Alpha.png"), typeof(Texture2D)) as Texture2D;
            mat.SetTexture("_MainTex", _mainTex);
            mat.SetTexture("_AlphaTex", _alphaTex);
            #endregion

            GameObject go = null;
            UIAtlas uiAtlas = null;
            if ((go = AssetDatabase.LoadAssetAtPath(path.Replace(".png", ".prefab"), typeof(GameObject)) as GameObject) != null)
            {
                uiAtlas = SetAtlasInfo(go, path, mat);
            }
            else
            {
                go = new GameObject(ob.name);
                go.AddComponent<UIAtlas>();
                uiAtlas = SetAtlasInfo(go, path, mat);

                #region 第三步:创建预设
                CreatePrefab(go, ob.name, path);
                #endregion
            }
            AssetDatabase.SaveAssets();

            EditorUtility.ClearProgressBar();
        }
    }
开发者ID:yuisunn,项目名称:UnityCrazy,代码行数:49,代码来源:CreateNGUIAtlaesWithTPForETC1.cs

示例12: MakeMaterial

    private Material MakeMaterial()
    {
        Material newMaterial = new Material(Shader.Find("Standard"));
        newMaterial.SetFloat("_Mode", 1.0f);
        newMaterial.EnableKeyword("_ALPHATEST_ON");
        newMaterial.EnableKeyword("_NORMALMAP");
        newMaterial.SetTexture("_BumpMap", AssetDatabase.LoadAssetAtPath<Texture>("Assets/Sprites/Frogs/" + referencePath + "/Processed/" + referencePath.Replace(" ", "") + spriteName + "_NORMALS.png"));
        //newMaterial.SetTexture("_SpecGlossMap", AssetDatabase.LoadAssetAtPath<Texture>("Assets/Sprites/Frogs/" + referencePath + "/Processed/" + referencePath.Replace(" ", "") + spriteName + "_SPECULAR.png"));
        newMaterial.SetTexture("_ParallaxMap", AssetDatabase.LoadAssetAtPath<Texture>("Assets/Sprites/Frogs/" + referencePath + "/Processed/" + referencePath.Replace(" ", "") + spriteName + "_DEPTH.png"));
        newMaterial.SetTexture("_OcclusionMap", AssetDatabase.LoadAssetAtPath<Texture>("Assets/Sprites/Frogs/" + referencePath + "/Processed/" + referencePath.Replace(" ", "") + spriteName + "_OCCLUSION.png"));
        newMaterial.SetFloat("_Glossiness", 0);
        AssetDatabase.CreateAsset(newMaterial, "Assets/Sprites/Frogs/" + referencePath + "/" + referencePath.Replace(" ", "") + spriteName + ".mat");

        return AssetDatabase.LoadAssetAtPath<Material>("Assets/Sprites/Frogs/" + referencePath + "/" + referencePath.Replace(" ", "") + spriteName + ".mat");
    }
开发者ID:VCRhythm,项目名称:hotfrog,代码行数:15,代码来源:SpriteLoad.cs

示例13: UpdateMaterial

 protected override void UpdateMaterial()
 {
     Material material = new Material(base.GetCurrentSpriteDef().material);
     material.shader = Shader.Find(this.shaderName);
     material.SetTexture("_MaskTex", this.maskTexture);
     base.renderer.material = material;
 }
开发者ID:Lessica,项目名称:Something-of-SHIPWAR-GAMES,代码行数:7,代码来源:tk2dMaskedSprite.cs

示例14: Awake

    // Use this for initialization
    void Awake()
    {
        //Initalize render textures
        m_inputRenderTex = new RenderTexture(m_shadowSize, m_shadowSize, 0, RenderTextureFormat.ARGB32);
        m_middleRenderTex = new RenderTexture(m_shadowSize, 1, 0, RenderTextureFormat.ARGB32);

        //Initialize light material
        m_lightMaterial = new Material(Shader.Find("2DLighting/Deferred_Point_2"));
        m_lightMaterial.SetTexture("_DepthMap", m_middleRenderTex);
        m_lightMaterial.SetInt("_Penumbra", m_penumbra ? 1 : 0);
        m_lightMaterial.SetInt("_GradientFalloff", m_gradientFalloff ? 1 : 0);

        //Initialize phase one material
        phaseOneMaterial = new Material(Shader.Find("2DLighting/Deferred_Point_1"));
        phaseOneMaterial.SetFloat("_DistanceModifier", 0.001f);

        //Aquire camera component and initialize it
        m_camera = GetComponent<Camera>();
        m_camera.enabled = true;
        m_camera.targetTexture = m_inputRenderTex;

        //Create culling mask from given occluder layers
        int occluders = 0;
        for (int i = 0; i < m_occluderLayers.Count; i++)
        {
            occluders = occluders | (1 << LayerMask.NameToLayer(m_occluderLayers[i]));
        }
        m_camera.cullingMask = occluders;

        //Assign mesh material
        m_meshRenderer.material = m_lightMaterial;
    }
开发者ID:Dunnings,项目名称:Creative_Technologies,代码行数:33,代码来源:Shader_Light.cs

示例15: createMaterial

        public static Material createMaterial(FacadeSkin skin)
        {
            Material mat = new Material(Shader.Find("Standard (Specular setup)"));

            Texture2D colortex = getTexture(skin.colorTexturePath);
            Texture2D normaltex = getTexture(skin.normalTexturePath);
            Texture2D speculartex = getTexture(skin.specularTexturePath);

            mat.SetTexture("_MainTex", colortex);
            mat.SetTexture("_BumpMap", normaltex);
            mat.SetFloat("_BumpScale", 1.0f);
            mat.SetFloat("_Glossiness", 0.1f);
            mat.SetTexture("_SpecGlossMap", speculartex);

            return mat;
        }
开发者ID:hybrid1969,项目名称:Polimi-OSM-City-Engine,代码行数:16,代码来源:InGameTextureHandler.cs


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