SetMaterial() public method

Set the material for the canvas renderer. If a texture is specified then it will be used as the 'MainTex' instead of the material's 'MainTex'. See Also: CanvasRenderer.SetMaterialCount, CanvasRenderer.SetTexture.

public SetMaterial ( Material material, Texture texture ) : void
material Material Material for rendering.
texture Texture Material texture overide.
return void
コード例 #1
0
 public void SetMaterial(Material material, UnityEngine.Color ac)
 {
     if (canvasRenderer.GetMaterial() != material)
     {
         canvasRenderer.SetMaterial(material, null);
     }
     additionalColor = ac;
     buffer.modified = true;
 }
コード例 #2
0
 static public int SetMaterial(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(UnityEngine.Material), typeof(UnityEngine.Texture)))
         {
             UnityEngine.CanvasRenderer self = (UnityEngine.CanvasRenderer)checkSelf(l);
             UnityEngine.Material       a1;
             checkType(l, 2, out a1);
             UnityEngine.Texture a2;
             checkType(l, 3, out a2);
             self.SetMaterial(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.Material), typeof(int)))
         {
             UnityEngine.CanvasRenderer self = (UnityEngine.CanvasRenderer)checkSelf(l);
             UnityEngine.Material       a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             self.SetMaterial(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));
     }
 }
コード例 #3
0
    static int SetMaterial(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3 && TypeChecker.CheckTypes <int>(L, 3))
            {
                UnityEngine.CanvasRenderer obj  = (UnityEngine.CanvasRenderer)ToLua.CheckObject(L, 1, typeof(UnityEngine.CanvasRenderer));
                UnityEngine.Material       arg0 = (UnityEngine.Material)ToLua.CheckObject <UnityEngine.Material>(L, 2);
                int arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                obj.SetMaterial(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <UnityEngine.Texture>(L, 3))
            {
                UnityEngine.CanvasRenderer obj  = (UnityEngine.CanvasRenderer)ToLua.CheckObject(L, 1, typeof(UnityEngine.CanvasRenderer));
                UnityEngine.Material       arg0 = (UnityEngine.Material)ToLua.CheckObject <UnityEngine.Material>(L, 2);
                UnityEngine.Texture        arg1 = (UnityEngine.Texture)ToLua.ToObject(L, 3);
                obj.SetMaterial(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.CanvasRenderer.SetMaterial"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #4
0
 static public int SetMaterial(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
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(UnityEngine.Material), typeof(UnityEngine.Texture)))
         {
             UnityEngine.CanvasRenderer self = (UnityEngine.CanvasRenderer)checkSelf(l);
             UnityEngine.Material       a1;
             checkType(l, 2, out a1);
             UnityEngine.Texture a2;
             checkType(l, 3, out a2);
             self.SetMaterial(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.Material), typeof(int)))
         {
             UnityEngine.CanvasRenderer self = (UnityEngine.CanvasRenderer)checkSelf(l);
             UnityEngine.Material       a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             self.SetMaterial(a1, a2);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function SetMaterial to call");
         return(2);
     }
     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
 }
コード例 #5
0
 void Start()
 {
     arrowHead.sizeDelta = new Vector2 (arrowHead.rect.width * ARROW_HEAD_SCALE_COEFFICIENT, arrowHead.rect.height * ARROW_HEAD_SCALE_COEFFICIENT);
     arrowTail.sizeDelta = new Vector2 (arrowTail.rect.width, arrowTail.rect.height * ARROW_TAIL_SCALE_COEFFICIENT);
     scoreKeepingScript = GameObject.Find ("World").GetComponent<ScoreKeeping> ();
     ballManagerScript = GetComponent<BallManager> ();
     cameraFollowScript = camera3D.GetComponent<CameraFollow> ();
     levelManage = GameObject.Find ("LevelManager");
     levelManagerScript = levelManage == null ? null : levelManage.GetComponent<LevelManager> ();
     arrowTailRenderer = arrowTail.GetComponent<CanvasRenderer> ();
     arrowTailRenderer.SetMaterial (arrowTailShader, null);
     distance = 0;
     arrowScalePercent = 0;
     overUI = false;
 }
コード例 #6
0
 static public int SetMaterial(IntPtr l)
 {
     try{
         UnityEngine.CanvasRenderer self = (UnityEngine.CanvasRenderer)checkSelf(l);
         UnityEngine.Material       a1;
         checkType(l, 2, out a1);
         UnityEngine.Texture a2;
         checkType(l, 3, out a2);
         self.SetMaterial(a1, a2);
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #7
0
 static public int SetMaterial__Material__Texture(IntPtr l)
 {
     try {
         UnityEngine.CanvasRenderer self = (UnityEngine.CanvasRenderer)checkSelf(l);
         UnityEngine.Material       a1;
         checkType(l, 2, out a1);
         UnityEngine.Texture a2;
         checkType(l, 3, out a2);
         self.SetMaterial(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #8
0
ファイル: VectorLine.cs プロジェクト: t1mmmmY/Vectrosity
	private void SetupEndCap () {		
		m_capVertices = new UIVertex[8];
		Color32 endColor = color;
		if (m_UIVertices.Length > 0) {
			endColor = m_UIVertices[m_vertexCount-1].color;
		}
		for (int i = 0; i < 4; i++) {
			m_capVertices[i].color = color;
			m_capVertices[i+4].color = endColor;
		}
		
		m_capVertices[0].uv0 = new Vector2 (0.0f, .25f);
		m_capVertices[3].uv0 = new Vector2 (0.0f, 0.0f);
		m_capVertices[2].uv0 = new Vector2 (1.0f, 0.0f);
		m_capVertices[1].uv0 = new Vector2 (1.0f, .25f);
		if (capDictionary[m_endCap].capType == EndCap.Mirror) {
			m_capVertices[4].uv0 = new Vector2 (1.0f, .25f);
			m_capVertices[7].uv0 = new Vector2 (1.0f, 0.0f);
			m_capVertices[6].uv0 = new Vector2 (0.0f, 0.0f);
			m_capVertices[5].uv0 = new Vector2 (0.0f, .25f);
		}
		else {
			m_capVertices[4].uv0 = new Vector2 (0.0f, 1.0f);
			m_capVertices[7].uv0 = new Vector2 (0.0f, .75f);
			m_capVertices[6].uv0 = new Vector2 (1.0f, .75f);
			m_capVertices[5].uv0 = new Vector2 (1.0f, 1.0f);
		}
		
		if (m_capRenderer == null) {
			var capObject = new GameObject(name + " cap");
			m_capRenderer = capObject.AddComponent<CanvasRenderer>();
			m_capRenderer.SetMaterial (capDictionary[m_endCap].material, null);
			var rectTransform = capObject.AddComponent<RectTransform>();
			SetupTransform (rectTransform);
			capObject.transform.SetParent (m_vectorObject.transform, false);
		}
	}
コード例 #9
0
ファイル: VectorLine.cs プロジェクト: t1mmmmY/Vectrosity
	private void SetupFillObject () {		
		m_fillVertices = new UIVertex[m_vertexCount];
		
		if (m_fillRenderer == null) {
			var fillObject = new GameObject(name + " fill");
			m_fillRenderer = fillObject.AddComponent<CanvasRenderer>();
			m_fillRenderer.SetMaterial (m_material, null);
			var rectTransform = fillObject.AddComponent<RectTransform>();
			SetupTransform (rectTransform);
			fillObject.transform.SetParent (m_vectorObject.transform, false);
		}
		m_fillObjectSet = true;
	}
コード例 #10
0
ファイル: VectorLine.cs プロジェクト: t1mmmmY/Vectrosity
	protected void SetupLine (string lineName, Material useMaterial, float width, LineType lineType, Joins joins, bool use2D, bool usePoints, int count) {	
		m_continuous = (lineType == LineType.Continuous);
		m_is2D = use2D;
		m_isPoints = usePoints;
		if (joins == Joins.Fill && !m_continuous) {
			Debug.LogError ("VectorLine: Must use LineType.Continuous if using Joins.Fill for \"" + lineName + "\"");
			return;
		}
		if ( (m_is2D && m_points2 == null) || (!m_is2D && m_points3 == null) ) {
			Debug.LogError ("VectorLine: the points array is null for \"" + lineName + "\"");
			return;
		}
		m_pointsCount = count;
		name = lineName;
		if (!CheckPointCount (count)) return;
		
		m_maxWeldDistance = (width*2) * (width*2);
		m_joins = joins;
		
		if (useMaterial == null) {
			if (defaultMaterial == null) {
				defaultMaterial = new Material(Shader.Find ("UI/Default"));
			}
			m_material = defaultMaterial;
		}
		else {
			m_material = useMaterial;
		}
		
		if (_canvas == null) {
			SetCanvas();
		}
		m_vectorObject = new GameObject(name);
		m_vectorObject.transform.SetParent (_canvas.transform, false);
		m_on2DCanvas = true;
		m_canvasRenderer = m_vectorObject.AddComponent<CanvasRenderer>();
		m_canvasRenderer.SetMaterial (m_material, null);
		m_rectTransform = m_vectorObject.AddComponent<RectTransform>();
		SetupTransform (m_rectTransform);
		
		if (!SetVertexCount()) return;
		
		m_UIVertices = new UIVertex[m_vertexCount];
		SetUVs (0, MaxSegmentIndex());
		color = Color.white;
		m_lineWidths = new float[1];
		m_lineWidths[0] = width * .5f;
		if (!m_is2D) {
			m_screenPoints = new Vector3[m_vertexCount];
		}
		m_drawStart = 0;
		m_drawEnd = m_pointsCount-1;
		
		if (joins == Joins.Fill) {
			SetupFillObject();
		}
	}