AddColor() private method

private AddColor ( int nameID, Color value ) : void
nameID int
value Color
return void
Ejemplo n.º 1
0
	void Awake()
	{
		mb = new MaterialPropertyBlock();
		mb.AddColor("_Color",newColor);
		mb.AddColor("_TintColor",newColor);

		this.transform.renderer.SetPropertyBlock(mb);
	}
Ejemplo n.º 2
0
	void Awake()
	{
		mb = new MaterialPropertyBlock();
		mb.AddColor("_Color",newColor);
		mb.AddColor("_TintColor",newColor);

		foreach (Transform child in transform)
		{
			child.renderer.SetPropertyBlock(mb);
		}
	}
Ejemplo n.º 3
0
	public void SetColor(Color col)
	{
		mb = new MaterialPropertyBlock();
		mb.AddColor("_Color",col);
		mb.AddColor("_TintColor",col);
		
		foreach (Transform child in transform)
		{
			child.renderer.SetPropertyBlock(mb);
		}
	}
Ejemplo n.º 4
0
	public void SetColor(Color col)
	{

		mb = new MaterialPropertyBlock();

		foreach (Transform child in transform)
		{	
			//col.a = (1-child.localPosition.y*6)/2f;
			
			mb.AddColor("_Color",col);
			mb.AddColor("_TintColor",col);

			child.renderer.SetPropertyBlock(mb);
		}
	}
 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));
     }
 }
Ejemplo n.º 6
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);
	}
Ejemplo n.º 7
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);
	}
 static public int AddColor(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(System.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);
             return(0);
         }
         else if (matchType(l, 2, typeof(System.Int32), 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);
             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);
     }
 }
Ejemplo n.º 9
0
	void Awake()
	{
		mb = new MaterialPropertyBlock();
		mb.AddTexture("_MainTex",texture);

		foreach (Transform child in transform)
		{	defaultColor = child.renderer.material.color;


			Color newColor = defaultColor;
			//newColor.a = (1-child.localPosition.y*8)/2f;
			mb.AddColor("_Color",newColor);
			mb.AddColor("_TintColor",newColor);

			child.renderer.SetPropertyBlock(mb);
			child.renderer.material.SetTexture("_MainTex", texture);
		}
	}
 public void AddToMaterialPropertyBlock(MaterialPropertyBlock block)
 {
     UIPanelMaterialPropertyBlock.Node node = this.first;
     int num = this.count;
     while (true)
     {
         int num1 = num;
         num = num1 - 1;
         if (num1 <= 0)
         {
             break;
         }
         switch (node.type)
         {
             case UIPanelMaterialPropertyBlock.PropType.Float:
             {
                 block.AddFloat(node.property, [email protected]);
                 break;
             }
             case UIPanelMaterialPropertyBlock.PropType.Vector:
             {
                 block.AddVector(node.property, [email protected]);
                 break;
             }
             case UIPanelMaterialPropertyBlock.PropType.Color:
             {
                 block.AddColor(node.property, [email protected]);
                 break;
             }
             case UIPanelMaterialPropertyBlock.PropType.Matrix:
             {
                 block.AddMatrix(node.property, [email protected]);
                 break;
             }
         }
         node = node.next;
     }
 }
Ejemplo n.º 11
0
        // Update is called once per frame
        void Update()
        {
            m_playCenter = UserProfile.SafeAreaCenter;
            m_playRadius = UserProfile.SafeAreaRadius;

            for (int i = 0; i < m_warning.Length; i++)
            {
                var w = m_warning[i];
                float wdist = m_warnDistance;

                Vector3 center = transform.position + transform.rotation * m_playCenter;

                Vector3 track;
                Quaternion r;

                if (i == 0)
                {
                    m_solver.GetTrackerTransform(Tracker.LEFT, out track, out r);
                    var con = m_avatar.GetInput(Tracker.LEFT);
                    if (con == null)
                    {
                        w.enabled = false;
                        continue;
                    }
                    w.transform.localScale = Vector3.one * 0.5f;
                    wdist *= 0.5f;
                }
                else if (i == 1)
                {
                    m_solver.GetTrackerTransform(Tracker.RIGHT, out track, out r);
                    var con = m_avatar.GetInput(Tracker.RIGHT);
                    if (con == null)
                    {
                        w.enabled = false;
                        continue;
                    }
                    w.transform.localScale = Vector3.one * 0.5f;
                    wdist *= 0.5f;
                }
                else
                {
                    var con = m_avatar.GetInput(Tracker.HEAD);
                    if (con == null)
                    {
                        w.enabled = false;
                        continue;
                    }
                    m_solver.GetEyeTransform(out track, out r);
                    w.transform.localScale = Vector3.one * 1f;
                }

                Vector3 delta = track - center;

                delta.y = 0;

                float dist = m_playRadius * m_playRadius - delta.sqrMagnitude;
                float t = 1f - dist / (m_playRadius * m_playRadius);

                if (t > 0.1f && m_playRadius != 0)
                {
                    w.enabled = true;

                    delta.Normalize();

                    Vector3 pos = delta * m_playRadius + center;
                    pos.y = track.y;

                    w.transform.position = pos;
                    w.transform.LookAt(track);

                    float heading = Mathf.Atan(delta.z / delta.x);
                    if (delta.x < 0)
                        heading += Mathf.PI;

                    float arc = heading * m_playRadius;
                    float height = pos.y;

                    if (t > 1)
                    {
                        arc *= -1;
                    }

                    float bright = wdist - dist;
                    MaterialPropertyBlock block = new MaterialPropertyBlock();

                    if (t > 1 && i == 2)
                        block.AddColor("_TintColor", new Color(0, 1, 0, 0.1f));
                    else
                        block.AddColor("_TintColor", new Color(1, 0, 0, Mathf.Clamp01(bright) * 0.75f));

                    block.AddVector("_GridOffset", new Vector4(arc, height, w.transform.lossyScale.x, w.transform.lossyScale.y));

                    w.SetPropertyBlock(block);
                }
                else
                    w.enabled = false;
            }
        }
Ejemplo n.º 12
0
        protected override void IssueDrawCall()
        {
            if (m_cb == null)
            {
                m_cb = new CommandBuffer();
                m_cb.name = "MPLightRenderer";
                foreach (var c in m_cameras)
                {
                    if (c != null) c.AddCommandBuffer(CameraEvent.AfterLighting, m_cb);
                }

                m_mpb = new MaterialPropertyBlock();
                m_mpb.AddColor("_Color", GetLinearColor());

            }
            m_cb.Clear();

            if (m_hdr)
            {
                m_cb.SetRenderTarget(BuiltinRenderTextureType.CameraTarget);
            }
            else
            {
                m_cb.SetRenderTarget(BuiltinRenderTextureType.GBuffer3);
            }
            m_mpb.SetColor("_Color", GetLinearColor());
            m_mpb.SetFloat("g_size", m_size);
            m_mpb.SetFloat("_OcculusionStrength", m_occulusion_strength);
            m_mpb.SetColor("_HeatColor", GetLinearHeatColor());
            m_mpb.SetFloat("_HeatThreshold", m_heat_threshold);

            Matrix4x4 matrix = Matrix4x4.identity;
            m_actual_materials.ForEach(a =>
            {
                for (int i = 0; i < m_batch_count; ++i)
                {
                    m_cb.DrawMesh(m_expanded_mesh, matrix, a[i], 0, 0, m_mpb);
                }
            });
        }