Пример #1
0
    public void AssignParams()
    {
        var renderer = GetComponent<Renderer>();
        var trans = GetComponent<Transform>();
        var material = renderer.sharedMaterial;

        if (m_mpb == null)
        {
            m_mpb = new MaterialPropertyBlock();
            m_mpb.SetFloat("_ObjectID", m_id);
        }

        var pos = m_use_root_position ? trans.root.position : trans.position;
        var rot = m_use_root_rotation ? trans.root.rotation : trans.rotation;
        var scale = m_use_root_scale ? trans.root.lossyScale : trans.lossyScale;
        if(m_debug_log)
        {
            Debug.Log("pos: " + pos);
            Debug.Log("rot: " + rot);
            Debug.Log("scale: " + scale);
        }
        m_mpb.SetVector("_Position", pos);
        m_mpb.SetVector("_Rotation", new Vector4(rot.x, rot.y, rot.z, rot.w));
        m_mpb.SetVector("_Scale", scale);
        m_mpb.SetFloat("_LocalTime", m_local_time);
        for (int i = 0; i < m_fparams.Count; ++i)
        {
            m_mpb.SetFloat(m_fparams[i].key, m_fparams[i].value);
        }
        renderer.SetPropertyBlock(m_mpb);
    }
	static void CreateMaterial (GameObject go) {
		// Create a simple material asset
		if (go.GetComponent<Renderer>() != null)
		{
			Material material = new Material(go.GetComponent<Renderer>().sharedMaterial);
			material.CopyPropertiesFromMaterial(go.GetComponent<Renderer>().sharedMaterial);
			go.GetComponent<Renderer>().sharedMaterial = material;
			MaterialPropertyBlock block = new MaterialPropertyBlock();
			go.GetComponent<Renderer>().GetPropertyBlock(block);
			#if UNITY_EDITOR
			if(!Directory.Exists("Assets/Materials")) {
				AssetDatabase.CreateFolder("Assets", "Materials");
				AssetDatabase.Refresh();
			}

			string textureName = null;
			if (block.GetTexture(0).name != null) {
				textureName = block.GetTexture(0).name;
			} else {
				textureName = material.mainTexture.name;
			}
			AssetDatabase.CreateAsset(material, "Assets/Materials/" + textureName + ".mat");
			Debug.Log("Created material " + textureName + " for " + go.name);
			#endif
		}
	}
Пример #3
0
// fields

// properties
    static void MaterialPropertyBlock_isEmpty(JSVCall vc)
    {
        UnityEngine.MaterialPropertyBlock _this = (UnityEngine.MaterialPropertyBlock)vc.csObj;
        var result = _this.isEmpty;

        JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
    }
 static public int AddColor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(int), typeof(UnityEngine.Color)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             UnityEngine.Color a2;
             checkType(l, 3, out a2);
             self.AddColor(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.Color)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             UnityEngine.Color a2;
             checkType(l, 3, out a2);
             self.AddColor(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #5
0
 private void BindFrame()
 {
     if (this.propBlock == null)
     {
         this.propBlock = new MaterialPropertyBlock();
     }
     else
     {
         this.propBlock.Clear();
     }
     Vector2 vector2 = base.transform.worldToLocalMatrix.MultiplyVector(this.north);
     vector2.Normalize();
     Vector2 vector21 = new Vector2(-vector2.y, vector2.x);
     vector21 = vector21 * this.scalar;
     vector2 = vector2 * this.scalar;
     if (this.bindNorth)
     {
         this.propBlock.AddVector(CompassRenderProxy.g.kPropLensUp, vector2);
     }
     if (this.bindWest)
     {
         this.propBlock.AddVector(CompassRenderProxy.g.kPropLensRight, vector21);
     }
     if (this.bindForward)
     {
         this.propBlock.AddVector(CompassRenderProxy.g.kPropLensDir, this.forward);
     }
     base.renderer.SetPropertyBlock(this.propBlock);
 }
Пример #6
0
 static public int constructor(IntPtr l)
 {
     UnityEngine.MaterialPropertyBlock o;
     o = new UnityEngine.MaterialPropertyBlock();
     pushObject(l, o);
     return(1);
 }
Пример #7
0
	void OnValidate () {
		if (oldSprite==null || sprite!=oldSprite) {
			_mat = null;
		}
		Awake();
		oldSprite = sprite;
	}
Пример #8
0
		public string GetDebugString() {
			string str = "<b>SkyDebug Info - " + this.name + "</b>\n";
			Material mat = null;
			if(Application.isPlaying)	mat = GetComponent<Renderer>().material;
			else 						mat = GetComponent<Renderer>().sharedMaterial;

			str += mat.shader.name + "\n";
			str += "is supported: " + mat.shader.isSupported + "\n";
			mset.ShaderIDs[] bids = {new mset.ShaderIDs(), new mset.ShaderIDs()};
			bids[0].Link();
			bids[1].Link("1");

			str += "\n<b>Anchor</b>\n";
			mset.SkyAnchor anchor = this.GetComponent<mset.SkyAnchor>();
			if(anchor != null) {
				str += "Curr. sky: " + anchor.CurrentSky.name + "\n";
				str += "Prev. sky: " + anchor.PreviousSky.name + "\n";
			} else {
				str += "none\n";
			}

			str += "\n<b>Property Block</b>\n";
			if(block == null) block = new MaterialPropertyBlock();
			block.Clear();
			this.GetComponent<Renderer>().GetPropertyBlock(block);

			for(int i=0; i<2; ++i) {
				str += "Renderer Property block - blend ID " + i;

				if(printDetails) {
					str += "\nexposureIBL  " + block.GetVector(bids[i].exposureIBL);
					str += "\nexposureLM   " + block.GetVector(bids[i].exposureLM);
					
					str += "\nskyMin       " + block.GetVector(bids[i].skyMin);
					str += "\nskyMax       " + block.GetVector(bids[i].skyMax);			
					
					str += "\ndiffuse SH\n";
					for(int j=0; j<4; ++j) {
						str += block.GetVector(bids[i].SH[j]) + "\n";
					}
					str += "...\n";
				}

				Texture spec = block.GetTexture(bids[i].specCubeIBL);
				Texture sky = block.GetTexture(bids[i].skyCubeIBL);
				str += "\nspecCubeIBL  "; if(spec) str += spec.name; else str += "none";
				str += "\nskyCubeIBL   "; if(sky)  str += sky.name;  else str += "none";

				if(printDetails) {
					str += "\nskyMatrix\n" + block.GetMatrix(bids[i].skyMatrix);
					str += "\ninvSkyMatrix\n" + block.GetMatrix(bids[i].invSkyMatrix);
				}

				if(i==0) {
					str += "\nblendWeightIBL " + block.GetFloat(bids[i].blendWeightIBL);
				}
				str += "\n\n";
			}
			return str;
		}
Пример #9
0
	void Awake ()
	{
		mb = new MaterialPropertyBlock();
		
		if( useTint) colorType = "_TintColor";
		originalColor = this.renderer.material.GetColor(colorType);
	}
Пример #10
0
	public static void DrawCube(Vector3 position, Quaternion rotation, float size, Color color)
	{
		Matrix4x4 mat = Matrix4x4.TRS(position, rotation, size * Vector3.one);
		MaterialPropertyBlock block = new MaterialPropertyBlock();
		block.AddColor("_Color", color);
		Graphics.DrawMesh(solidCube, mat, material, 0, null, 0, block);
	}
Пример #11
0
 private void setSkinDamageProperty(MaterialPropertyBlock block)
 {
     if (this.skin)
     {
         this.skin.SetPropertyBlock(block);
     }
 }
 public void SetOffset(Vector4 offset)
 {
     MaterialPropertyBlock props = new MaterialPropertyBlock();
     GetComponent<Renderer>().GetPropertyBlock(props);
     props.AddVector(offsetID, offset);
     GetComponent<Renderer>().SetPropertyBlock(props);
 }
 static public int SetColor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(int), typeof(UnityEngine.Color)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             UnityEngine.Color a2;
             checkType(l, 3, out a2);
             self.SetColor(a1, a2);
             return(0);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.Color)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             UnityEngine.Color a2;
             checkType(l, 3, out a2);
             self.SetColor(a1, a2);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int GetTexture(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(int)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             var ret = self.GetTexture(a1);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             var ret = self.GetTexture(a1);
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int AddVector(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(System.String), typeof(UnityEngine.Vector4)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector4 a2;
             checkType(l, 3, out a2);
             self.AddVector(a1, a2);
             return(0);
         }
         else if (matchType(l, 2, typeof(System.Int32), typeof(UnityEngine.Vector4)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             UnityEngine.Vector4 a2;
             checkType(l, 3, out a2);
             self.AddVector(a1, a2);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
    public virtual void LateUpdate()
    {
        if(m_id==0)
        {
            m_id = ++s_idgen;
        }
        m_local_time += Time.deltaTime;

        if (m_mpb == null)
        {
            m_renderer = GetComponent<Renderer>();
            m_trans = GetComponent<Transform>();
            m_mpb = new MaterialPropertyBlock();
            m_mpb.AddVector("_Position", Vector4.zero);
            m_mpb.AddVector("_Rotation", Vector4.zero);
            m_mpb.AddVector("_Scale", Vector4.one);
            m_mpb.AddFloat("_LocalTime", m_local_time);
            m_mpb.AddFloat("_ID", m_id);
        }

        var rot = m_trans.rotation;
        m_mpb.SetVector("_Position", m_trans.position);
        m_mpb.SetVector("_Rotation", new Vector4(rot.x, rot.y, rot.z, rot.w));
        m_mpb.SetVector("_Scale", m_trans.localScale);
        m_mpb.SetFloat("_LocalTime", m_local_time);
        for (int i = 0; i < m_params.Length; ++i)
        {
            m_mpb.SetFloat(m_params[i].key, m_params[i].value);
        }
        m_renderer.SetPropertyBlock(m_mpb);
    }
Пример #17
0
	public void OnWillRenderObject()
	{
		if (m_MatProps == null)
			m_MatProps = new MaterialPropertyBlock();

		Camera cam = Camera.current;
		cam.depthTextureMode |= DepthTextureMode.Depth;

		m_MatProps.Clear();
		m_MatProps.AddVector("_CameraLocalPos", transform.InverseTransformPoint(cam.transform.position));
		m_MatProps.AddMatrix("_CameraToLocal", transform.worldToLocalMatrix * cam.transform.localToWorldMatrix);
		m_MatProps.AddVector("_Scale", transform.localScale);
		m_MatProps.AddFloat("_Brightness", m_Brightness);

		if (Application.isPlaying)
		{
			float time = Time.time;
			m_TimeElapsed += m_Speed * (time - m_LastFrameTime);
			m_LastFrameTime = time;
			Shader.SetGlobalFloat("_FireTime", m_StartTime + m_TimeElapsed);
		}
		else
		{
			Shader.SetGlobalFloat("_FireTime", m_StartTime);
		}

		renderer.SetPropertyBlock(m_MatProps);
	}
Пример #18
0
 private void Awake()
 {
     this._alpha = 0.001f;
     this._renderer = base.GetComponent<Renderer>();
     this._block = new MaterialPropertyBlock();
     base.enabled = false;
 }
Пример #19
0
 void Start()
 {
     property_block = new MaterialPropertyBlock();
     property_block.AddMatrix("prev_Object2World", Matrix4x4.identity);
     mesh_renderer = GetComponent<MeshRenderer>();
     mesh_renderer.SetPropertyBlock(property_block);
 }
Пример #20
0
 private void Start()
 {
     this.bloodPropertyBlock = new MaterialPropertyBlock();
     this.animator = base.transform.GetComponentInChildren<Animator>();
     this.resetSkinDamage();
     base.InvokeRepeating("setSkinDamage", 1f, 0.3f);
 }
 public override void SetTexture(Texture2D texture)
 {
     base.SetTexture(texture);
     MaterialPropertyBlock props = new MaterialPropertyBlock();
     props.AddTexture("_MainTex", texture);
     spriteRenderer.SetPropertyBlock(props);
 }
Пример #22
0
    public void SwapColors_Custom(ColorPalette palette)
    {
        Texture2D t = spriteRenderer.sprite.texture;

        if (palette.cachedTexture == null)
        {
            var w = t.width;
            var h = t.height;

            var cloneTexture = new Texture2D(w, h);
            cloneTexture.wrapMode = TextureWrapMode.Clamp;
            cloneTexture.filterMode = FilterMode.Point;

            var colors = t.GetPixels();

            for (int i = 0; i < colors.Length; i++)
            {
                colors[i] = palette.GetColor(colors[i]);
            }

            cloneTexture.SetPixels(colors);
            cloneTexture.Apply();

            palette.cachedTexture = cloneTexture;
        }

        block = new MaterialPropertyBlock();
        block.AddTexture("_MainTex", palette.cachedTexture);
    }
Пример #23
0
    void Update()
    {
        if (_props == null)
            _props = new MaterialPropertyBlock();

        var dx = Mathf.Sin(_slideSpeed * Time.time) * _interval;
        var br = (Mathf.Cos(_blinkSpeed * Time.time) + 1) * 0.5f;

        var origin = transform.position + new Vector3(
                _interval * _columns * -0.5f + dx,
                _interval * _columns * -0.5f, 0);
        var rotation = transform.rotation;
        var scale = Vector3.one * _cellSize;

        for (var y = 0; y <= _columns; y++)
        {
            for (var x = 0; x <= _columns; x++)
            {
                var position = origin + new Vector3(x, y, 0) * _interval;
                var matrix = Matrix4x4.TRS(position, rotation, scale);

                var c1 = _color1 * (br * x / _columns);
                var c2 = _color2 * (br * y / _columns);
                _props.SetColor("_EmissionColor", c1 + c2);

                Graphics.DrawMesh(_mesh, matrix, _material, 0, null, 0, _props);
            }
        }
    }
 public static void SetupMaterialPropertyBlock(MaterialProperty materialProp, int changedMask, Renderer target)
 {
   MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();
   target.GetPropertyBlock(materialPropertyBlock);
   materialProp.WriteToMaterialPropertyBlock(materialPropertyBlock, changedMask);
   target.SetPropertyBlock(materialPropertyBlock);
 }
Пример #25
0
	public static void DrawSphere(Vector3 position, float radius, Color color)
	{
		Matrix4x4 mat = Matrix4x4.TRS(position, Quaternion.identity, radius * 0.5f * Vector3.one);
		MaterialPropertyBlock block = new MaterialPropertyBlock();
		block.AddColor("_Color", color);
		Graphics.DrawMesh(solidSphere, mat, material, 0, null, 0, block);
	}
Пример #26
0
	void Awake()
	{
		mb = new MaterialPropertyBlock();
		mb.AddColor("_Color",newColor);
		mb.AddColor("_TintColor",newColor);

		this.transform.renderer.SetPropertyBlock(mb);
	}
Пример #27
0
 /// <summary>
 /// <para>Get the previously set splat material properties by copying to the dest MaterialPropertyBlock object.</para>
 /// </summary>
 /// <param name="dest"></param>
 public void GetSplatMaterialPropertyBlock(MaterialPropertyBlock dest)
 {
     if (dest == null)
     {
         throw new ArgumentNullException("dest");
     }
     this.Internal_GetSplatMaterialPropertyBlock(dest);
 }
Пример #28
0
 void UpdateOutline(bool outline)
 {
     MaterialPropertyBlock mpb = new MaterialPropertyBlock();
     spriteRenderer.GetPropertyBlock(mpb);
     mpb.SetFloat("_Outline", outline ? 1f : 0);
     mpb.SetColor("_OutlineColor", color);
     spriteRenderer.SetPropertyBlock(mpb);
 }
        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();
            }
        }
Пример #30
0
 // Use this for initialization
 void Start()
 {
     MaterialPropertyBlock bloc = new MaterialPropertyBlock();
     Renderer rend = gameObject.GetComponent<Renderer> ();
     rend.material = SpriteLightMaterial;
     rend.GetPropertyBlock (bloc);
     bloc.AddTexture ("_LightTex",Light.texture);
     rend.SetPropertyBlock (bloc);
 }
Пример #31
0
 private void ApplyChanges()
 {
     if (render == null) return;
     if(block == null) block = new MaterialPropertyBlock();
     render.GetPropertyBlock(block);
     block.SetFloat("TileScale", 1.0f / tileScale);
     block.SetVector("ObjectSize", transform.localScale);
     render.SetPropertyBlock(block);
 }
Пример #32
0
  protected virtual void Awake() {
    _handModel = GetComponent<HandModel>();
    _renderer = GetComponentInChildren<Renderer>();

    _fadePropertyBlock = new MaterialPropertyBlock();
    _renderer.GetPropertyBlock(_fadePropertyBlock);
    _fadePropertyBlock.SetFloat("_Fade", 0);
    _renderer.SetPropertyBlock(_fadePropertyBlock);
  }
Пример #33
0
 void Start()
 {
     matBlock = new MaterialPropertyBlock();
     colorId = Shader.PropertyToID("_TintColor");
     //for (int i = 33; i <= 103; i += 10)
     //{
     //    print("midi: " + i + " -> " + NoteDecorator.midiToDegree(i, 90));
     //}
 }
Пример #34
0
    // Use this for initialization
    void Start()
    {
        // We use the default fractal color set in the Mandelbrot shader
        m_propBlock = new MaterialPropertyBlock();
        m_propBlock.AddVector("_ColorRatio", new Vector4(1.0f,1.0f,1.0f,1.0f));
        Viewport.GetComponent<Renderer>().SetPropertyBlock(m_propBlock);

        StartMusic();
    }
Пример #35
0
 static public int SetFloatArray(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(string), typeof(List <System.Single>)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             System.Collections.Generic.List <System.Single> a2;
             checkType(l, 3, out a2);
             self.SetFloatArray(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(int), typeof(List <System.Single>)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             System.Collections.Generic.List <System.Single> a2;
             checkType(l, 3, out a2);
             self.SetFloatArray(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(System.Single[])))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             System.Single[] a2;
             checkArray(l, 3, out a2);
             self.SetFloatArray(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(int), typeof(System.Single[])))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             System.Single[] a2;
             checkArray(l, 3, out a2);
             self.SetFloatArray(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #36
0
	// Update is called once per frame
	void Update () {
		Debug.Log (Mathf.Abs( Mathf.Cos (Time.time)));
		var material = gameObject.GetComponent<SpriteRenderer> ().material;
		material.SetFloat ("ShineLocation", Mathf.Abs( Mathf.Cos (Time.time)));

		MaterialPropertyBlock pb = new MaterialPropertyBlock ();
		gameObject.GetComponent<SpriteRenderer> ().GetPropertyBlock(pb);
		pb.SetFloat ("ShineLocation", Mathf.Abs (Mathf.Cos (Time.time)));
		gameObject.GetComponent<SpriteRenderer> ().SetPropertyBlock (pb);
	}
Пример #37
0
 IEnumerator Start()
 {
     _materialProperties = new MaterialPropertyBlock();
     while (true)
     {
         ChangeMaterial();
         GetComponent<Renderer>().SetPropertyBlock(_materialProperties);
         yield return new WaitForSeconds(0.5f);
     }
 }
Пример #38
0
 public void Unapply()
 {
     UnityEngine.Renderer renderer = this.transform.GetComponent <UnityEngine.Renderer>();
     if (renderer != null && this.materialPropertyBlock != null)
     {
         this.materialPropertyBlock.Clear();
         renderer.SetPropertyBlock(this.materialPropertyBlock);
         this.materialPropertyBlock = null;
     }
 }
Пример #39
0
    public bool Apply()
    {
        bool continueNextFrame = false;

        UnityEngine.Renderer renderer = this.transform.GetComponent <UnityEngine.Renderer>();
        if (renderer != null)
        {
            if (this.materialPropertyBlock == null)
            {
                this.materialPropertyBlock = new UnityEngine.MaterialPropertyBlock();
            }

            renderer.GetPropertyBlock(this.materialPropertyBlock);
            {
                int propertyCount = this.PropertyColors != null ? this.PropertyColors.Length : 0;
                for (int i = 0; i < propertyCount; ++i)
                {
                    bool needAnimation = this.PropertyColors[i].AddToMaterialPropertyBlock(this.materialPropertyBlock);
                    continueNextFrame |= needAnimation;
                }
            }

            {
                int propertyCount = this.PropertyVectors != null ? this.PropertyVectors.Length : 0;
                for (int i = 0; i < propertyCount; ++i)
                {
                    bool needAnimation = this.PropertyVectors[i].AddToMaterialPropertyBlock(this.materialPropertyBlock);
                    continueNextFrame |= needAnimation;
                }
            }

            {
                int propertyCount = this.PropertyFloats != null ? this.PropertyFloats.Length : 0;
                for (int i = 0; i < propertyCount; ++i)
                {
                    bool needAnimation = this.PropertyFloats[i].AddToMaterialPropertyBlock(this.materialPropertyBlock);
                    continueNextFrame |= needAnimation;
                }
            }

            {
                int propertyCount = this.PropertyMatrices != null ? this.PropertyMatrices.Length : 0;
                for (int i = 0; i < propertyCount; ++i)
                {
                    bool needAnimation = this.PropertyMatrices[i].AddToMaterialPropertyBlock(this.materialPropertyBlock);
                    continueNextFrame |= needAnimation;
                }
            }

            renderer.SetPropertyBlock(this.materialPropertyBlock);
        }

        return(continueNextFrame);
    }
Пример #40
0
    // Use this for initialization
    void Start()
    {
        //ひとつのMeshObjectには、65000頂点まで入る。ので、限界まで、元になるメッシュ(origin)のデータを詰め込んだメッシュ(mesh)を作る。
        //mesh.uv2.xの値をそれぞれ、指定しておくことで、shader内で個別に処理できるようにしている。
        CreateMesh();

        numDraw = numMeshes / numInSingleMesh;
        if (numDraw * numInSingleMesh < numMeshes)
            numDraw++;
        mPropBlock = new MaterialPropertyBlock();
    }
 static public int get_isEmpty(IntPtr l)
 {
     try {
         UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
         pushValue(l, self.isEmpty);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 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));
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.MaterialPropertyBlock o;
         o = new UnityEngine.MaterialPropertyBlock();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    static bool Renderer_SetPropertyBlock__MaterialPropertyBlock(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            UnityEngine.MaterialPropertyBlock arg0 = (UnityEngine.MaterialPropertyBlock)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            ((UnityEngine.Renderer)vc.csObj).SetPropertyBlock(arg0);
        }

        return(true);
    }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.MaterialPropertyBlock o;
         o = new UnityEngine.MaterialPropertyBlock();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.MaterialPropertyBlock o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.MaterialPropertyBlock();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
 static public int SetMatrixArray(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.Matrix4x4[])))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             UnityEngine.Matrix4x4[] a2;
             checkType(l, 3, out a2);
             self.SetMatrixArray(a1, a2);
             return(0);
         }
         else if (matchType(l, argc, 2, typeof(int), typeof(UnityEngine.Matrix4x4[])))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             UnityEngine.Matrix4x4[] a2;
             checkType(l, 3, out a2);
             self.SetMatrixArray(a1, a2);
             return(0);
         }
         else if (matchType(l, argc, 2, typeof(string), typeof(List <UnityEngine.Matrix4x4>)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.String a1;
             checkType(l, 2, out a1);
             System.Collections.Generic.List <UnityEngine.Matrix4x4> a2;
             checkType(l, 3, out a2);
             self.SetMatrixArray(a1, a2);
             return(0);
         }
         else if (matchType(l, argc, 2, typeof(int), typeof(List <UnityEngine.Matrix4x4>)))
         {
             UnityEngine.MaterialPropertyBlock self = (UnityEngine.MaterialPropertyBlock)checkSelf(l);
             System.Int32 a1;
             checkType(l, 2, out a1);
             System.Collections.Generic.List <UnityEngine.Matrix4x4> a2;
             checkType(l, 3, out a2);
             self.SetMatrixArray(a1, a2);
             return(0);
         }
         return(error(l, "No matched override function to call"));
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 public static int GetPropertyBlock_wrap(long L)
 {
     try
     {
         long     nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L);
         Renderer obj      = get_obj(nThisPtr);
         UnityEngine.MaterialPropertyBlock arg0 = FCGetObj.GetObj <UnityEngine.MaterialPropertyBlock>(FCLibHelper.fc_get_intptr(L, 0));
         obj.GetPropertyBlock(arg0);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
Пример #49
0
    static bool Graphics_DrawMesh__Mesh__Matrix4x4__Material__Int32__Camera__Int32__MaterialPropertyBlock(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 7)
        {
            UnityEngine.Mesh                  arg0 = (UnityEngine.Mesh)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Matrix4x4             arg1 = (UnityEngine.Matrix4x4)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Material              arg2 = (UnityEngine.Material)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.Int32                      arg3 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            UnityEngine.Camera                arg4 = (UnityEngine.Camera)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.Int32                      arg5 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            UnityEngine.MaterialPropertyBlock arg6 = (UnityEngine.MaterialPropertyBlock)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Graphics.DrawMesh(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
        }

        return(true);
    }
Пример #50
0
    static bool Graphics_DrawMesh__Mesh__Vector3__Quaternion__Material__Int32__Camera__Int32__MaterialPropertyBlock__Boolean__Boolean(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 10)
        {
            UnityEngine.Mesh                  arg0 = (UnityEngine.Mesh)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Vector3               arg1 = (UnityEngine.Vector3)JSApi.getVector3S((int)JSApi.GetType.Arg);
            UnityEngine.Quaternion            arg2 = (UnityEngine.Quaternion)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Material              arg3 = (UnityEngine.Material)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.Int32                      arg4 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            UnityEngine.Camera                arg5 = (UnityEngine.Camera)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.Int32                      arg6 = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
            UnityEngine.MaterialPropertyBlock arg7 = (UnityEngine.MaterialPropertyBlock)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.Boolean                    arg8 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
            System.Boolean                    arg9 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
            UnityEngine.Graphics.DrawMesh(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
        }

        return(true);
    }
        static int _m_GetPropertyBlock(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.Renderer __cl_gen_to_be_invoked = (UnityEngine.Renderer)translator.FastGetCSObj(L, 1);


            try {
                {
                    UnityEngine.MaterialPropertyBlock dest = (UnityEngine.MaterialPropertyBlock)translator.GetObject(L, 2, typeof(UnityEngine.MaterialPropertyBlock));

                    __cl_gen_to_be_invoked.GetPropertyBlock(dest);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
        static int _m_GetPropertyBlock(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.Renderer gen_to_be_invoked = (UnityEngine.Renderer)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && translator.Assignable <UnityEngine.MaterialPropertyBlock>(L, 2))
                {
                    UnityEngine.MaterialPropertyBlock _properties = (UnityEngine.MaterialPropertyBlock)translator.GetObject(L, 2, typeof(UnityEngine.MaterialPropertyBlock));

                    gen_to_be_invoked.GetPropertyBlock(_properties);



                    return(0);
                }
                if (gen_param_count == 3 && translator.Assignable <UnityEngine.MaterialPropertyBlock>(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    UnityEngine.MaterialPropertyBlock _properties = (UnityEngine.MaterialPropertyBlock)translator.GetObject(L, 2, typeof(UnityEngine.MaterialPropertyBlock));
                    int _materialIndex = LuaAPI.xlua_tointeger(L, 3);

                    gen_to_be_invoked.GetPropertyBlock(_properties, _materialIndex);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Renderer.GetPropertyBlock!"));
        }
Пример #53
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();
    }
Пример #54
0
 extern private static void Internal_DrawMeshInstancedIndirect(Mesh mesh, int submeshIndex, Material material, Bounds bounds, ComputeBuffer bufferWithArgs, int argsOffset, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, int layer, Camera camera, LightProbeUsage lightProbeUsage, LightProbeProxyVolume lightProbeProxyVolume);
Пример #55
0
 public bool AddToMaterialPropertyBlock(UnityEngine.MaterialPropertyBlock materialPropertyBlock)
 {
     materialPropertyBlock.SetFloat(this.PropertyName, this.PropertyValue);
     return(false);
 }
Пример #56
0
 extern public void SetSplatMaterialPropertyBlock(MaterialPropertyBlock properties);
Пример #57
0
 extern private void Internal_GetSplatMaterialPropertyBlock(MaterialPropertyBlock dest);
Пример #58
0
 internal extern void MakeMaterialProperties(MaterialPropertyBlock properties, Camera camera);
Пример #59
0
 extern private static void Internal_DrawMesh(Mesh mesh, int submeshIndex, Matrix4x4 matrix, Material material, int layer, Camera camera, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, Transform probeAnchor, LightProbeUsage lightProbeUsage, LightProbeProxyVolume lightProbeProxyVolume);
Пример #60
0
 extern private static void Internal_DrawMeshInstancedProcedural(Mesh mesh, int submeshIndex, Material material, Bounds bounds, int count, MaterialPropertyBlock properties, ShadowCastingMode castShadows, bool receiveShadows, int layer, Camera camera, LightProbeUsage lightProbeUsage, LightProbeProxyVolume lightProbeProxyVolume);