Clear() private method

private Clear ( ) : void
return void
Ejemplo n.º 1
1
 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);
 }
Ejemplo n.º 2
0
 static public int Clear(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
         self.Clear();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
        public void TransferToUnityComponents(Entity entity, IBindingContext context)
        {
            try
            {
                var spriteRenderer   = context.GetUnityComponent <UnityEngine.SpriteRenderer>(entity);
                var sprite2DRenderer = context.GetComponentData <Sprite2DRenderer>(entity);
                var sprite           = context.GetUnityObject <UnityEngine.Sprite>(sprite2DRenderer.sprite);

                var block = new UnityEngine.MaterialPropertyBlock();
                spriteRenderer.GetPropertyBlock(block);
                block.Clear();

                spriteRenderer.color = sprite2DRenderer.color.Convert();
                block.SetColor("_Color", sprite2DRenderer.color.Convert());

                if (sprite)
                {
                    spriteRenderer.sprite = sprite;
                    var blending = sprite2DRenderer.blending;
                    if (k_BlendModes.TryGetValue(blending, out var blendMode))
                    {
                        spriteRenderer.sharedMaterial.SetFloat("_SrcMode", blendMode.x);
                        spriteRenderer.sharedMaterial.SetFloat("_DstMode", blendMode.y);
                    }
                    else
                    {
                        UnityEngine.Debug.Log($"Tiny: Unknown blending mode, of value '{blending}'");
                    }

                    block.SetTexture("_MainTex", sprite.texture);
                }
                else
                {
                    spriteRenderer.sprite = s_WhiteSprite;
                    if (!context.HasComponent <Sprite2DRendererOptions>(entity))
                    {
                        spriteRenderer.size = UnityEngine.Vector2.one;
                    }
                }

                spriteRenderer.SetPropertyBlock(block);

                if (context.HasComponent <Sprite2DRendererOptions>(entity))
                {
                    var options = context.GetComponentData <Sprite2DRendererOptions>(entity);
                    SetDrawMode(spriteRenderer, options.drawMode);
                    spriteRenderer.size = options.size;
                }
                else
                {
                    spriteRenderer.drawMode = UnityEngine.SpriteDrawMode.Simple;
                }
            }
            finally
            {
                UnityEditor.SceneView.RepaintAll();
            }
        }
 static public int Clear(IntPtr l)
 {
     try {
         UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
         self.Clear();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 5
0
 static int Clear(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.MaterialPropertyBlock obj = (UnityEngine.MaterialPropertyBlock)ToLua.CheckObject(L, 1, typeof(UnityEngine.MaterialPropertyBlock));
         obj.Clear();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 6
0
    protected void ApplyToRenderers()
    {
        UnityEngine.Debug.Assert(this.exportToLocal);
        if (materialPropertyBlock == null)
        {
            materialPropertyBlock = new UnityEngine.MaterialPropertyBlock();
        }

        int datasLength = this.Datas != null ? this.Datas.Length : 0;

        this.FindRenderers(renderers);
        int renderersCount = renderers.Count;

        for (int i = 0; i < renderersCount; ++i)
        {
            renderers[i].GetPropertyBlock(materialPropertyBlock);
            materialPropertyBlock.SetBuffer(this.BufferName, this.computeBuffer);
            materialPropertyBlock.SetFloat(this.bufferSizeName, datasLength);
            renderers[i].SetPropertyBlock(materialPropertyBlock);
            materialPropertyBlock.Clear();
        }

        renderers.Clear();
    }
Ejemplo n.º 7
0
    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);
    }
 public void Clear()
 {
     unityPropertyBlock.Clear();
     locallySetProperties.Clear();
 }
Ejemplo n.º 9
-1
		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;
			}
		}