當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。