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


C# MaterialPropertyBlock.Clear方法代码示例

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


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

示例1: InitializeColorChangeSystem

 private void InitializeColorChangeSystem() {
     _primaryMeshMPB = new MaterialPropertyBlock();  // default color is black
     _primaryMeshRenderer.GetPropertyBlock(_primaryMeshMPB);
     _primaryMeshMPB.Clear();    // in case the renderer had properties other than the default properties
                                 // renderer's existing MaterialPropertyBlock color is also black, implying that the existing property block is the default, at least wrt color
     _primaryMeshRenderer.SetPropertyBlock(_primaryMeshMPB);
 }
开发者ID:Maxii,项目名称:CodeEnv.Master,代码行数:7,代码来源:AElementDisplayManager.cs

示例2: UpdateMaterial

    void UpdateMaterial()
    {
        if (! initialised) {
            // Parameters changed before Awake() has been run, do a full update when appropriate.
            // (Can't rely on Awake() when the GameObject is disabled. It does a lousy job as a constructor.)
            regenerateMesh = true;
            return;
        }

        if ((renderer.sharedMaterials.Length != 1) || (renderer.sharedMaterials[0] != m_material)) {
            // Update only when necessary to prevent false scene changes.
            renderer.sharedMaterials = new Material[] {m_material};
        }

        MaterialPropertyBlock materialProperties = new MaterialPropertyBlock();
        renderer.GetPropertyBlock(materialProperties);

        if ((m_sprite != null) && (m_sprite.texture != null)) {
            materialProperties.SetTexture("_MainTex", m_sprite.texture);
        }
        else if (m_material != null) {
            if (materialProperties.GetTexture("_MainTex") != null) {
                materialProperties.Clear();
            }
            m_material.SetTexture("_MainTex", null);
        }

        renderer.SetPropertyBlock(materialProperties);
    }
开发者ID:ChubbRck,项目名称:SFB,代码行数:29,代码来源:TiledSpriteRenderer.cs

示例3: EditorApplyToList

		private void EditorApplyToList(object[] renderers, mset.SkyApplicator[] apps, bool forceApply) {
			foreach(object mr in renderers) {
				Renderer rend = (Renderer)mr;

				//filter by ignored layers
				int layerFlag = 1 << rend.gameObject.layer;
				if( (IgnoredLayerMask & layerFlag) != 0 ) continue;
				if(!rend.gameObject.activeInHierarchy) continue;

				#if USE_PROPERTY_BLOCKS
				//HACK: force clear all property blocks just in case
				if(forceApply) {
					MaterialPropertyBlock pb = new MaterialPropertyBlock();
					pb.Clear();
					rend.SetPropertyBlock(pb);
				}
				#endif
				//mset.Sky.ScrubKeywords(rend.sharedMaterials);

				mset.SkyAnchor anchor = rend.gameObject.GetComponent<mset.SkyAnchor>();
				if(anchor && !anchor.enabled) anchor = null;
				
				bool rendHasChanged = rend.transform.hasChanged || (anchor && anchor.HasChanged);
				bool localFound = false;
				
				if(anchor && anchor.BindType == mset.SkyAnchor.AnchorBindType.TargetSky) {
					anchor.Apply();
					localFound = true;
				}
				//trigger stuff is only processed if the game will auto apply as well
				if(GameAutoApply && !localFound) {
					foreach(mset.SkyApplicator app in apps) {
						if(!app.gameObject.activeInHierarchy) continue;
						if(app.TargetSky) {
							if(forceApply || app.HasChanged || app.TargetSky.Dirty || rendHasChanged) {
								localFound |= app.ApplyInside(rend);
								app.TargetSky.Dirty = false;
							}
						}
						app.HasChanged = false;
					}
				}
				
				if(!localFound && _GlobalSky) {
					if(forceApply || _GlobalSky.Dirty || rendHasChanged) {
						_GlobalSky.Apply(rend,0);
					}
				}
				//HACK: we are checking and clearing hasChanged in a weird place during the editor loop. Hopefully that won't conflict with other plugins?
				rend.transform.hasChanged = false;
				if(anchor) anchor.HasChanged = false;
			}

			//this is always called in EditorUpdate, only run if forced externally
			if(forceApply && _GlobalSky) {
				_GlobalSky.Apply(0);
				if(_SkyboxMaterial) {
					_GlobalSky.Apply(_SkyboxMaterial, 0);
				}
				_GlobalSky.Dirty = false;
			}
		}
开发者ID:keyward,项目名称:EnemyOfMyEnemy,代码行数:62,代码来源:SkyManager.cs


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