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


C# Material.SetFloat方法代码示例

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


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

示例1: Start

 // Use this for initialization
 void Start()
 {
     mat = GetComponent<Renderer> ().material;
     mat.SetColor ("_EnergyColor", energyColor);
     mat.SetFloat ("_Visibility", visibility);
     mat.SetFloat ("_CollisionTime", -99f); // To ensure that animation is already "over" by the time we start.
 }
开发者ID:Vwing,项目名称:Breakout,代码行数:8,代码来源:ForceField.cs

示例2: DrawProteinsAtoms

    public static void DrawProteinsAtoms(Material renderProteinsMaterial, Camera camera, RenderBuffer instanceId, RenderBuffer atomId, RenderBuffer depthBuffer, int pass)
    {
        // Protein params
        renderProteinsMaterial.SetInt("_EnableLod", Convert.ToInt32(GlobalProperties.Get.EnableLod));
        renderProteinsMaterial.SetFloat("_Scale", GlobalProperties.Get.Scale);
        renderProteinsMaterial.SetFloat("_FirstLevelBeingRange", GlobalProperties.Get.FirstLevelOffset);
        renderProteinsMaterial.SetVector("_CameraForward", camera.transform.forward);

        renderProteinsMaterial.SetBuffer("_LodLevelsInfos", GPUBuffers.Get.LodInfo);
        renderProteinsMaterial.SetBuffer("_ProteinInstanceInfo", GPUBuffers.Get.ProteinInstancesInfo);
        renderProteinsMaterial.SetBuffer("_ProteinInstancePositions", GPUBuffers.Get.ProteinInstancePositions);
        renderProteinsMaterial.SetBuffer("_ProteinInstanceRotations", GPUBuffers.Get.ProteinInstanceRotations);

        renderProteinsMaterial.SetBuffer("_ProteinColors", GPUBuffers.Get.IngredientsColors);
        renderProteinsMaterial.SetBuffer("_ProteinAtomInfo", GPUBuffers.Get.ProteinAtomInfo);
        renderProteinsMaterial.SetBuffer("_ProteinAtomPositions", GPUBuffers.Get.ProteinAtoms);
        renderProteinsMaterial.SetBuffer("_ProteinClusterPositions", GPUBuffers.Get.ProteinAtomClusters);
        renderProteinsMaterial.SetBuffer("_ProteinSphereBatchInfos", GPUBuffers.Get.SphereBatches);

        /****/
        renderProteinsMaterial.SetInt("_NumCutObjects", SceneManager.Get.NumCutObjects);
        renderProteinsMaterial.SetInt("_NumIngredientTypes", SceneManager.Get.NumAllIngredients);
        

        renderProteinsMaterial.SetBuffer("_CutInfos", GPUBuffers.Get.CutInfo);
        renderProteinsMaterial.SetBuffer("_CutScales", GPUBuffers.Get.CutScales);
        renderProteinsMaterial.SetBuffer("_CutPositions", GPUBuffers.Get.CutPositions);
        renderProteinsMaterial.SetBuffer("_CutRotations", GPUBuffers.Get.CutRotations);
        /****/

        Graphics.SetRenderTarget(new[] { instanceId, atomId }, depthBuffer);
        renderProteinsMaterial.SetPass(1);
        Graphics.DrawProceduralIndirect(MeshTopology.Points, GPUBuffers.Get.ArgBuffer);
    }
开发者ID:matmuze,项目名称:cellVIEW_color,代码行数:34,代码来源:RenderUtils.cs

示例3: Update

	void Update()
	{
		terrain = GetComponent<Terrain>();
		tData = terrain ? terrain.terrainData : null;
		tMaterial = terrain ? terrain.materialTemplate : null;
		if (!terrain || !tData || !tMaterial)
			return;
		
		if(disableBasemap && !Application.isPlaying && GetComponent<Terrain>().basemapDistance != 1000000) // only reset on update in edit mode
			GetComponent<Terrain>().basemapDistance = 1000000;
		if (cutoutMode)
		{
			if (tMaterial.HasProperty("_CutoutModeHideAlpha") && tMaterial.GetFloat("_CutoutModeHideAlpha") != cutoutModeHideAlpha)
				tMaterial.SetFloat("_CutoutModeHideAlpha", cutoutModeHideAlpha);
		}
		else
			if (tMaterial.HasProperty("_CutoutModeHideAlpha") && tMaterial.GetFloat("_CutoutModeHideAlpha") != -1)
				tMaterial.SetFloat("_CutoutModeHideAlpha", -1);

		if (!Application.isPlaying)
			ApplyTransparencyMap();
		else
			if (!transparencyMap && autoUpdateTransparencyMap)
			{
				UpdateTransparencyMap();
				ApplyTransparencyMap();
			}
			else
				ApplyTransparencyMap();
	}
开发者ID:theomission,项目名称:ozUnity,代码行数:30,代码来源:TerrainTransparency.cs

示例4: 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

示例5: Start

    // Use this for initialization
    void Start () {

        waterZones = GameObject.FindGameObjectsWithTag("InteractableWater");

        currentWeather = Weather.CLEAR;
        day = true;

        skybox = RenderSettings.skybox;

        skybox.SetFloat("_DayToNight", 0f);
        skybox.SetFloat("_RainToSnow", 0f);
        skybox.SetFloat("_NormalToRainSnow", 0f);
        skybox.SetFloat("_RainSnowToSpecial", 0f);

        mainLight = FindObjectOfType<Light>();

        foreach (Material m in materials)
        {
            m.SetFloat("_Snow", 0f);
        }

        rain = GameObject.Find("PS_Rain");
        snow = GameObject.Find("PS_Snowflakes");
        other = GameObject.Find("PS_weather");

        rain.SetActive(false);
        snow.SetActive(false);
        other.SetActive(false);

        tM = FindObjectOfType<TrackManager>();

        SetAurore(false);
    }
开发者ID:Miformat,项目名称:GlobalGameJam,代码行数:34,代码来源:MeteoManager.cs

示例6: updateSprite

    void updateSprite(SpriteRenderer spriteRenderer, AlphaMaskScript mask)
    {
        Texture2D a = mask.clipTexture;
        Texture2D b = spriteRenderer.sprite.texture;
        float w1 = (float)a.width;
        float h1 = (float)a.height;
        float w2 = (float)b.width;
        float h2 = (float)b.height;
        float xScale = h1 / h2;
        float yScale = w1 / w2;
        float adjustScale = xScale > yScale ? yScale : xScale;
        xScale = xScale / adjustScale / mask.scale;
        yScale = yScale / adjustScale / mask.scale;
        float xOffset = mask.xOffsetPixel / w2;
        float yOffset = mask.yOffsetPixel / h2;

        var mat = new Material(Shader.Find("Unlit/AlphaMask"));
        mat.name = mask.ToName();
        mat.SetTexture("_ClipTex", mask.clipTexture);
        mat.SetFloat("_xScale", xScale);
        mat.SetFloat("_yScale", yScale);
        mat.SetFloat("_xOffset", xOffset);
        mat.SetFloat("_yOffset", yOffset);

        spriteRenderer.sharedMaterial = mat;

        Debug.Log(string.Format(
            "update alpha mask target={0}x{1} mask={2}x{3}",
            w1,
            h1,
            w2,
            h2
        ));
    }
开发者ID:hythof,项目名称:UnityAlphaMaskShader,代码行数:34,代码来源:AlphaMaskScriptInspector.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: DrawProteinSphereBatches

    public static void DrawProteinSphereBatches(Material renderProteinsMaterial, Camera camera, RenderBuffer colorBuffer, RenderBuffer depthBuffer, int pass, bool animated = false)
    {
        // Protein params
        renderProteinsMaterial.SetInt("_EnableLod", Convert.ToInt32(PersistantSettings.Instance.EnableLod));
        renderProteinsMaterial.SetFloat("_Scale", PersistantSettings.Instance.Scale);
        renderProteinsMaterial.SetFloat("_FirstLevelBeingRange", PersistantSettings.Instance.FirstLevelOffset);
        renderProteinsMaterial.SetVector("_CameraForward", camera.transform.forward);

        renderProteinsMaterial.SetBuffer("_LodLevelsInfos", GPUBuffers.Instance.LodInfo);
        renderProteinsMaterial.SetBuffer("_ProteinInstanceInfo", GPUBuffers.Instance.ProteinInstanceInfo);

        if(animated) renderProteinsMaterial.SetBuffer("_ProteinInstancePositions", GPUBuffers.Instance.ProteinAnimationPositions);
        else renderProteinsMaterial.SetBuffer("_ProteinInstancePositions", GPUBuffers.Instance.ProteinInstancePositions);

        if (animated) renderProteinsMaterial.SetBuffer("_ProteinInstanceRotations", GPUBuffers.Instance.ProteinAnimationRotations);
        else renderProteinsMaterial.SetBuffer("_ProteinInstanceRotations", GPUBuffers.Instance.ProteinInstanceRotations);

        renderProteinsMaterial.SetBuffer("_ProteinAtomCount", GPUBuffers.Instance.ProteinAtomCount);
        renderProteinsMaterial.SetBuffer("_ProteinColors", GPUBuffers.Instance.ProteinColors);
        renderProteinsMaterial.SetBuffer("_ProteinAtomPositions", GPUBuffers.Instance.ProteinAtoms);
        renderProteinsMaterial.SetBuffer("_ProteinClusterPositions", GPUBuffers.Instance.ProteinAtomClusters);
        renderProteinsMaterial.SetBuffer("_ProteinSphereBatchInfos", GPUBuffers.Instance.SphereBatches);

        Graphics.SetRenderTarget(colorBuffer, depthBuffer);
        renderProteinsMaterial.SetPass(pass);
        Graphics.DrawProceduralIndirect(MeshTopology.Points, GPUBuffers.Instance.ArgBuffer);
    }
开发者ID:jaronimoe,项目名称:cellVIEW_animated,代码行数:27,代码来源:RenderUtils.cs

示例9: UpdateMeshHeights

    public void UpdateMeshHeights(Material material, float minHeight, float maxHeight)
    {
        savedMinHeight = minHeight;
        savedMaxHeight = maxHeight;

        material.SetFloat("minHeight", minHeight);
        material.SetFloat("maxHeight", maxHeight);
    }
开发者ID:rense,项目名称:Procedural-Landmass-Generation,代码行数:8,代码来源:TextureData.cs

示例10: createMaterials

    private void createMaterials()
    {
        gameMaterial = new Material(GameShader);
        gameMaterial.SetFloat("_GridStepX", 1.0f/Width);
        gameMaterial.SetFloat("_GridStepY", 1.0f/Height);

        edgeDetectMaterial = new Material(EdgeDetectShader);
    }
开发者ID:NabilNoaman,项目名称:unite-12,代码行数:8,代码来源:GameOfLife.cs

示例11: getMaterial

	public Material getMaterial(){
		if (material == null) {
			material = new Material(Shader.Find("Custom/2D Tile Shader"));
			material.SetTexture("_Tex", texture);
			material.SetFloat("_Width", width);
			material.SetFloat("_Height", height);
		}
		return material;
	}
开发者ID:JBillingsley,项目名称:eecs-390-rts,代码行数:9,代码来源:TextureAtlas.cs

示例12: Awake

 void Awake()
 {
     if(!grayscaleMaterial)
     {
         grayscaleMaterial = new Material(BDAShaderLoader.GrayscaleEffectShader);
         grayscaleMaterial.SetTexture("_RampTex", textureRamp);
         grayscaleMaterial.SetFloat("_RedPower", rampOffset);
         grayscaleMaterial.SetFloat("_RedDelta", rampOffset);
     }
 }
开发者ID:gomker,项目名称:BDArmory,代码行数:10,代码来源:TGPCameraEffects.cs

示例13: Awake

 // Use this for initialization
 void Awake()
 {
     MeshRenderer rend = GetComponent<MeshRenderer>();
     shockwaveDistortionMat = rend.material = Instantiate(rend.material);
     Callback.DoLerp((float l) =>
     {
         shockwaveDistortionMat.SetFloat("_MaxRange", l / 2);
         shockwaveDistortionMat.SetFloat("_Annulus", 1 - (l * l));
     }, time, this);
 }
开发者ID:Reddeyfish,项目名称:Witches-vs-Aliens-2015-2016,代码行数:11,代码来源:DistortionShockwave.cs

示例14: Apply

		public void Apply(ConfigNode node)
		{
			//create scaled material and set proprties to defaults
			scaledMaterial = new Material (Shaders.EmissiveScaled);
			scaledMaterial.SetTextureScale ("_EmissiveMap", Vector2.one);
			scaledMaterial.SetTextureOffset ("_EmissiveMap", Vector2.zero);
			scaledMaterial.SetColor ("_Color", new Color (1f, 1f, 1f));
			scaledMaterial.SetFloat ("_Brightness", 1.25f);
			scaledMaterial.SetFloat ("_Transparency", 0.75f);
		}
开发者ID:HappyFaceIndustries,项目名称:KopernicusExpansion,代码行数:10,代码来源:EmissiveEffectsLoader.cs

示例15: Start

 public void Start()
 {
     fxRes = GetComponent<IndieEffects>();
     mat = new Material(shader);
     mat.SetColor("_Lift", Lift);
     mat.SetFloat("_LiftB", Mathf.Clamp(LiftBright, 0f, 2f));
     mat.SetColor("_Gamma", Gamma);
     mat.SetFloat("_GammaB", Mathf.Clamp(GammaBright, 0f, 2f));
     mat.SetColor("_Gain", Gain);
     mat.SetFloat("_GainB", Mathf.Clamp(GainBright, 0f, 2f));
 }
开发者ID:GreatArcStudios,项目名称:UnityIndieEffects,代码行数:11,代码来源:ColorBalance.cs


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