本文整理汇总了C#中UnityEngine.CanvasRenderer.SetMaterial方法的典型用法代码示例。如果您正苦于以下问题:C# CanvasRenderer.SetMaterial方法的具体用法?C# CanvasRenderer.SetMaterial怎么用?C# CanvasRenderer.SetMaterial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.CanvasRenderer
的用法示例。
在下文中一共展示了CanvasRenderer.SetMaterial方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
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;
}
示例2: SetupEndCap
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);
}
}
示例3: SetupFillObject
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;
}
示例4: SetupLine
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();
}
}