Esempio n. 1
0
    void Start()

    {
        viewMesh      = new Mesh();
        viewMesh.name = "view Mesh";
        //viewMeshFilter.mesh = viewMesh;
        canvas.Clear();
        canvas.SetMesh(viewMesh);
        canvas.SetMaterial(material, 0);
    }
Esempio n. 2
0
    private void HideLetters(VertexHelper vh)
    {
        var lenght = original.Count;
        var zero   = Vector3.zero;

        for (var i = 0; i < lenght; ++i)
        {
            var uiVer = modified[i];
            uiVer.position = zero;
            modified[i]    = uiVer;
        }
        vh.AddUIVertexTriangleStream(modified);
        vh.FillMesh(_mesh);
        _canvasRendered.SetMesh(_mesh);
    }
Esempio n. 3
0
    private void GenerateMesh()
    {
        int count = values.Count;

        if (count > 0)
        {
            _mesh = new Mesh();

            _vertices  = new Vector3[count + 1];
            _uv        = new Vector2[count + 1];
            _triangles = new int[3 * count];

            float angleIncrement = 360f / count;
            float radarChartSize = 145f;


            // uv
            _uv[0] = Vector2.zero;
            for (int i = 0; i < count; i++)
            {
                _uv[i + 1] = Vector2.one;
            }

            // vertices and tris
            _vertices[0] = Vector3.zero;
            for (int i = 0; i < count; i++)
            {
                _vertices[i + 1] = Quaternion.Euler(0, 0, -angleIncrement * i) * Vector3.up * radarChartSize * values[i].GetFraction;

                // Tris
                _triangles[i * 3] = 0;
                for (int j = 0; j < 2; j++)
                {
                    _triangles[i * 3 + j + 1] = i + j + 1;
                }
            }
            _triangles[3 * count - 1] = 1;
            _fullVertices             = new Vector3[count + 1];
            Array.Copy(_vertices, _fullVertices, _vertices.Length);

            _mesh.vertices  = _vertices;
            _mesh.uv        = _uv;
            _mesh.triangles = _triangles;

            canvasRenderer.SetMesh(_mesh);
            canvasRenderer.SetMaterial(chartMaterial, null);
        }
    }
Esempio n. 4
0
    private void UpdateStatsVisual()
    {
        Mesh mesh = new Mesh();

        Vector3[] vertices  = new Vector3[6];
        Vector2[] uv        = new Vector2[6];
        int[]     triangles = new int[3 * 5];

        float angleIncrement = 360f / 5;
        float radarChartSize = 99f;

        Vector3 attackVertex       = Quaternion.Euler(0, 0, -angleIncrement * 0) * Vector3.up * radarChartSize * stats.GetStatAmountNormalized(Stats.Type.Attack);
        int     attackVertexIndex  = 1;
        Vector3 defenceVertex      = Quaternion.Euler(0, 0, -angleIncrement * 1) * Vector3.up * radarChartSize * stats.GetStatAmountNormalized(Stats.Type.Defence);
        int     defenceVertexIndex = 2;
        Vector3 speedVertex        = Quaternion.Euler(0, 0, -angleIncrement * 2) * Vector3.up * radarChartSize * stats.GetStatAmountNormalized(Stats.Type.Speed);
        int     speedVertexIndex   = 3;
        Vector3 manaVertex         = Quaternion.Euler(0, 0, -angleIncrement * 3) * Vector3.up * radarChartSize * stats.GetStatAmountNormalized(Stats.Type.Mana);
        int     manaVertexIndex    = 4;
        Vector3 healthVertex       = Quaternion.Euler(0, 0, -angleIncrement * 4) * Vector3.up * radarChartSize * stats.GetStatAmountNormalized(Stats.Type.Health);
        int     healthVertexIndex  = 5;

        vertices[0] = Vector3.zero;
        vertices[attackVertexIndex]  = attackVertex;
        vertices[defenceVertexIndex] = defenceVertex;
        vertices[speedVertexIndex]   = speedVertex;
        vertices[manaVertexIndex]    = manaVertex;
        vertices[healthVertexIndex]  = healthVertex;

        triangles[0] = 0;
        triangles[1] = attackVertexIndex;
        triangles[2] = defenceVertexIndex;

        triangles[3] = 0;
        triangles[4] = defenceVertexIndex;
        triangles[5] = speedVertexIndex;

        triangles[6] = 0;
        triangles[7] = speedVertexIndex;
        triangles[8] = manaVertexIndex;

        triangles[9]  = 0;
        triangles[10] = manaVertexIndex;
        triangles[11] = healthVertexIndex;

        triangles[12] = 0;
        triangles[13] = healthVertexIndex;
        triangles[14] = attackVertexIndex;



        mesh.vertices  = vertices;
        mesh.uv        = uv;
        mesh.triangles = triangles;

        raderMeshCanvasRenderer.SetMesh(mesh);
        raderMeshCanvasRenderer.SetMaterial(radarMaterial, null);
        //transform.Find("attackBar").localScale = new Vector3(1, stats.GetStatAmountNormalized(Stats.Type.Attack));
        //transform.Find("defenceBar").localScale = new Vector3(1, stats.GetStatAmountNormalized(Stats.Type.Defence));
    }
    public void UpdateStatusMesh(float[] normalizedValues)
    {
        if (chartMesh)
        {
            Destroy(chartMesh);
        }
        chartMesh = new Mesh();
        Vector3[] vertices   = new Vector3[normalizedValues.Length + 1];
        int[]     triangles  = new int[3 * normalizedValues.Length];
        float     deltaAngle = 360f / normalizedValues.Length;

        vertices[0] = Vector3.zero;
        for (int i = 0; i < normalizedValues.Length; i++)
        {
            vertices[i + 1]      = GetVerticesPos(normalizedValues[i], deltaAngle * i);
            triangles[i * 3]     = 0;
            triangles[i * 3 + 1] = i + 1;
            triangles[i * 3 + 2] = i + 2 >= normalizedValues.Length + 1 ? 1 : i + 2;
        }
        chartMesh.vertices  = vertices;
        chartMesh.triangles = triangles;

        canvasRenderer.SetMesh(chartMesh);
        canvasRenderer.SetMaterial(chartMaterial, null);
    }
        public void UpdateMesh()
        {
            if (m_ActorNode == null || m_Mesh == null || m_ActorNode.VertexCount == 0)
            {
                return;
            }
            m_ActorNode.UpdateVertexPositionBuffer(m_VertexPositionBuffer);

            int numVerts = m_VertexPositionBuffer.Length / 2;
            int readIdx  = 0;

            Vector3[] verts = m_Mesh.vertices;
            for (int i = 0; i < numVerts; i++)
            {
                float x = m_VertexPositionBuffer[readIdx++];
                float y = m_VertexPositionBuffer[readIdx++];
                verts[i] = new Vector3(x, y, 0.0f);
            }
            m_Mesh.vertices = verts;

            byte alpha = (byte)(255.0f * m_ActorNode.RenderOpacity);

            if (m_Mesh.colors32[0].a != alpha)
            {
                Color32[] colors = new Color32[m_Mesh.colors32.Length];
                for (int i = 0; i < colors.Length; i++)
                {
                    colors[i] = new Color32(255, 255, 255, alpha);
                }
                m_Mesh.colors32 = colors;
            }
            m_Renderer.SetMesh(m_Mesh);
        }
Esempio n. 7
0
 void Update()
 {
     mesh.Clear();
     mesh.vertices  = datas.verts.ToArray();
     mesh.triangles = datas.triganles.ToArray();
     canvasRenderer.SetMesh(mesh);
 }
Esempio n. 8
0
    // Update is called once per frame
    void Update()
    {
        CanvasRenderer cr = GetComponent <CanvasRenderer>();

        cr.SetMesh(meshFilter.sharedMesh);
        transform.localScale = new Vector3(500, 500, 500);
    }
Esempio n. 9
0
 void ApplyChangesIfAny(bool force = false)
 {
     if (somethingChanged || transform.hasChanged || force)
     {
         //Dont allow radius to be negative
         if (innerRadius < 0)
         {
             innerRadius = 0f;
         }
         if (outerRadius < 0)
         {
             outerRadius = 0f;
         }
         //Don't allow inner radius to be bigger than outter radius
         if (innerRadius >= outerRadius)
         {
             outerRadius = innerRadius + 0.1f;
         }
         if (outerRadius <= innerRadius)
         {
             innerRadius = outerRadius - 0.1f;
         }
         //When generating a star, we only allow even numbr of sectors larger or equal than 6
         //6 sectors is a star with 3 points
         if (starrines > 0)
         {
             if (sectorCount < 6)
             {
                 sectorCount = 6;
             }
             if (sectorCount % 2 != 0)
             {
                 sectorCount++;
             }
         }
         MakeMesh();
         if (isCanvas)
         {
             if (cr == null)
             {
                 cr = GetComponent <CanvasRenderer>();
             }
             cr.SetMesh(mesh);
         }
         else
         {
             if (mf == null)
             {
                 mf = GetComponent <MeshFilter>();
             }
             mf.sharedMesh = mesh;
         }
         if (mr != null)
         {
             mr.sortingLayerID = sortingLayer;
             mr.sortingOrder   = orderInLayer;
         }
     }
 }
Esempio n. 10
0
    private void DrawBarChart()
    {
        if (controller.SeriesCount < 1)
        {
            return;
        }


        float mBarHeight = chartHolder.rect.height;
        float mBarSector = chartHolder.rect.width / controller.SeriesCount;
        float mBarWidth  = mBarSector * 0.67f;

        for (int idx = 0; idx < controller.SeriesCount; idx++)
        {
            float     x        = (idx + 0.5f) * mBarSector;
            float     y        = controller.values[idx] / controller.GetTotalMaxValue() * mBarHeight;
            Vector3[] lines    = new Vector3[] { new Vector3(x, 0), new Vector3(x, y) };
            Mesh      lineMesh = ChartUtils.GenerateLineMesh(lines, mBarWidth);

            string         name     = ChartUtils.NameGenerator(chartChildString, idx);
            GameObject     obj      = chartHolder.Find(name).gameObject;
            CanvasRenderer renderer = obj.GetComponent <CanvasRenderer>();

            renderer.Clear();
            renderer.SetMaterial(controller.materials[idx], null);
            renderer.SetMesh(lineMesh);

            RectTransform rt;
            if (obj.transform.childCount > 0)
            {
                rt = obj.transform.GetChild(0) as RectTransform;
            }
            else
            {
                var go = new GameObject();
                go.transform.SetParent(obj.transform);

                var t = go.AddComponent <Text>();
                t.alignment = TextAnchor.MiddleCenter;
                t.color     = Color.black;
                t.font      = font;

                rt = go.transform as RectTransform;
            }

            rt.localPosition = new Vector3(x, -7);

            var text = obj.GetComponentInChildren <Text>();
            if (text != null)
            {
                text.text = controller.values[idx].ToString();
            }
        }
    }
Esempio n. 11
0
    /// <summary>
    /// Method  to draw / display the 2D Radar Chart within the UI.
    /// </summary>
    /// <param name="mesh">Mesh of the 2D Radar Chart representing the selected Time Slice in the 3D Radar Chart.</param>
    private void setRadarChart2DMesh(Mesh mesh)
    {
        // set the mesh
        timeSliceRadarUICanvasRenderer.SetMesh(mesh);

        // set color
        Material polygonMeshMat = new Material(Shader.Find("UI/Default"));

        polygonMeshMat.color = tdrcInterface.cnfgTmSlcRdrUI_radarColor;
        timeSliceRadarUICanvasRenderer.SetMaterial(polygonMeshMat, null);
    }
Esempio n. 12
0
        protected override void UpdateGeometry()
        {
            base.UpdateGeometry();
            if (shouldEmojilize)
            {
                CreateEmojiCanvasRenderer();

                emojiVh.FillMesh(emojiWorkMesh);
                emojiCanvasRenderer.SetMesh(emojiWorkMesh);
            }
        }
Esempio n. 13
0
    /// <summary>
    /// Redraw the axis based on the lenght and height of the chart area.
    /// </summary>
    private void UpdateAxis()
    {
        lines    = new Vector3[4];
        lines[0] = Vector3.zero;
        lines[1] = new Vector3(0, axisHolder.rect.height);
        lines[2] = lines[0];
        lines[3] = new Vector3(axisHolder.rect.width, 0);
        axisMesh = ChartUtils.GenerateLineMesh(lines, 2f);

        //canvasRenderer.Clear();
        canvasRenderer.SetMaterial(ChartUtils.BlackMaterial, null);
        canvasRenderer.SetMesh(axisMesh);
    }
Esempio n. 14
0
    // Use this for initialization
    void Start()
    {
        renderer = GetComponent <CanvasRenderer>();

        mesh = new Mesh();
        mesh.SetVertices(new List <Vector3>(points));
        mesh.SetTriangles(new int[] { 0, 1, 2 }, 0);
        renderer.Clear();
        renderer.SetMaterial(material, null);
        renderer.SetMesh(mesh);

        player = FindObjectOfType <PlayerController>();
    }
    void DrawSprite()
    {
        Mesh m_spriteMesh = new Mesh();

        List <Vector3> tempVertices  = new List <Vector3>();
        List <Vector2> tempUv        = new List <Vector2>();
        List <int>     tempTriangles = new List <int>();

        for (int i = 0; i < listSprite.Count; i++)
        {
            for (int j = 0; j < listSprite[i].vertices.Length; j++)
            {
                tempVertices.Add(listSprite[i].vertices[j]);
            }
            for (int j = 0; j < listSprite[i].uv.Length; j++)
            {
                tempUv.Add(listSprite[i].uv[j]);
            }
            for (int j = 0; j < listSprite[i].triangles.Length; j++)
            {
                tempTriangles.Add(listSprite[i].triangles[j]);
            }
        }

        for (int i = 0; i < tempTriangles.Count; i++)
        {
            if (i % 6 == 0)
            {
                int num = i / 6;
                tempTriangles[i]     = 0 + 4 * num;
                tempTriangles[i + 1] = 1 + 4 * num;
                tempTriangles[i + 2] = 2 + 4 * num;

                tempTriangles[i + 3] = 1 + 4 * num;
                tempTriangles[i + 4] = 0 + 4 * num;
                tempTriangles[i + 5] = 3 + 4 * num;
            }
        }

        m_spriteMesh.vertices  = tempVertices.ToArray();
        m_spriteMesh.uv        = tempUv.ToArray();
        m_spriteMesh.triangles = tempTriangles.ToArray();

        if (m_spriteCanvasRenderer == null)
        {
            m_spriteCanvasRenderer = m_spriteGraphic.GetComponent <CanvasRenderer>();
        }

        m_spriteCanvasRenderer.SetMesh(m_spriteMesh);
        m_spriteGraphic.UpdateMaterial();
    }
Esempio n. 16
0
    protected override void UpdateGeometry()
    {
        base.UpdateGeometry();
        if (mesh == null)
        {
            return;
        }
        if (renderer == null)
        {
            renderer = GetComponent <CanvasRenderer>();
        }
        Vector3 offset = Vector3.zero;

        if (drawCenter)
        {
            Mesh temp = new Mesh();
            //オフセットの計算
            offset = -mesh.bounds.center;
            Vector3[] vertices = mesh.vertices;
            for (int i = 0; i < vertices.Length; ++i)
            {
                vertices[i] += offset;
            }
            //頂点などの設定
            temp.vertices = vertices;
            temp.uv       = mesh.uv;
            temp.colors   = mesh.colors;
            temp.SetIndices(mesh.GetIndices(0), mesh.GetTopology(0), 0);
            //再計算
            temp.RecalculateBounds();
            temp.RecalculateNormals();
            renderer.SetMesh(temp);
        }
        else
        {
            renderer.SetMesh(mesh);
        }
    }
Esempio n. 17
0
 void ShowProgressionCircle()
 {
     _mesh        = new Mesh();
     _vertices    = new Vector3[_levelCount * 3];
     _vertices[0] = new Vector3(0f, 0f, 0f) * 10f;
     _vertices[1] = new Vector3(0f, 1f, 0f) * 10f;
     _vertices[2] = new Vector3(-1f, 1f, 0f) * 10f;
     // _vertices[3] = new Vector3(-1f,0f,0f) * 10f;
     _mesh.vertices  = _vertices;
     _mesh.uv        = new Vector2[] { new Vector2(1 - 1f / _resolution, 1), new Vector2(1, 1), new Vector2(1, 1) };
     _mesh.triangles = new int[] { 0, 1, 2 };
     _renderer.SetMaterial(_material, _texture);
     _renderer.SetMesh(_mesh);
 }
Esempio n. 18
0
        protected override void UpdateGeometry()
        {
#if UNITY_EDITOR
            textDirty = true;
#endif
            base.UpdateGeometry();
            if (shouldEmojilize)
            {
                CreateEmojiCanvasRenderer();

                emojiVh.FillMesh(emojiWorkMesh);
                emojiCanvasRenderer.SetMesh(emojiWorkMesh);
            }
        }
 void Start()
 {
     if (m_ActorNode == null)
     {
         return;
     }
     m_Renderer = GetComponent <CanvasRenderer>();
     m_Renderer.Clear();
     m_Renderer.SetAlpha(1.0f);
     m_Renderer.SetColor(Color.white);
     m_Renderer.SetMesh(m_Mesh);
     m_Renderer.materialCount = 1;
     m_Renderer.SetMaterial(m_Material, 0);
     m_VertexPositionBuffer = m_ActorNode.MakeVertexPositionBuffer();
 }
Esempio n. 20
0
 void Canvas_willRenderCanvases()
 {
     if (!IsDirty || Mesh == null)
     {
         return;
     }
     IsDirty        = false;
     Mesh.vertices  = Vertices;
     Mesh.triangles = Indices;
     CanvasRenderer.SetMesh(Mesh);
     CanvasRenderer.SetColor(Color);
     CanvasRenderer.materialCount = 1;
     CanvasRenderer.SetMaterial(Canvas.GetDefaultCanvasMaterial(), 0);
     CanvasRenderer.SetTexture(Texture2D.whiteTexture);
     CanvasRenderer.SetAlpha(0.5f);
 }
Esempio n. 21
0
        public static void MakeRect(CanvasRenderer canvasRender, Vector2 topLeft, Vector2 bottomRight, Material m)
        {
            Vector2[] m_points2 = new Vector2[5];
            int       index     = 0;

            m_points2[index]     = new Vector2(topLeft.x, topLeft.y);
            m_points2[index + 1] = new Vector2(bottomRight.x, topLeft.y);
            m_points2[index + 2] = new Vector2(bottomRight.x, bottomRight.y);
            m_points2[index + 3] = new Vector2(topLeft.x, bottomRight.y);
            m_points2[index + 4] = new Vector2(topLeft.x, topLeft.y);

            List <Vector3> lis = getListDot(m_points2, 1);

            canvasRender.SetMaterial(m, null);
            canvasRender.SetMesh(getNewMesh(lis));
        }
Esempio n. 22
0
    /// <summary>
    /// Method to create the mesh representing the 2D Radar Chart.
    /// </summary>
    /// <param name="fpcList">List of FrequencyPointComponent instances representing the 2D Radar Chart.</param>
    /// <param name="polygonColor">Color32 value representing the color used for the created 2D Radar Chart mesh.</param>
    /// <returns>Reference to the created mesh.</returns>
    private Mesh displayRadarForFrequencyPointComponentList(List <TDRCFrequencyPointComponent> fpcList, Color32 polygonColor)
    {
        // init mesh and required variables
        Mesh                   polygonMesh = new Mesh();
        List <Vector2>         meshPoints  = new List <Vector2>();
        List <int>             indices     = null;
        List <Vector3>         vertices    = null;
        List <List <Vector2> > holesList   = new List <List <Vector2> >();

        // setup mesh coordinates
        for (int i = 0; i < fpcList.Count; i++)
        {
            float   yPos = TDRCFrequencyPolygon.getDataValueForVisualizationBasedOnTDRCInterfaceConfig(fpcList[i].fp.value, tdrcInterface); // transform original data value based on configured options
            Vector2 pos  = RotateVector(new Vector2(0.0f, yPos), 360.0f / fpcList.Count * i);
            meshPoints.Add(pos);
        }

        // perform Triangulation
        // Developer Note: This is based on the implemented PolyExtruder package, Source: https://github.com/nicoversity/unity_polyextruder
        Triangulation.triangulate(meshPoints, holesList, 0.0f, out indices, out vertices);

        // update mesh with new data
        polygonMesh.Clear();
        polygonMesh.vertices  = vertices.ToArray();
        polygonMesh.triangles = indices.ToArray();
        polygonMesh.RecalculateNormals();
        polygonMesh.RecalculateBounds();

        // setup mesh in the UI GameObject
        // Note: TimeSliceRenderer GameObject needs to have the correct rotation (see below) and scale (inherited from interface configuration):
        //  - Rotation: x: 0, y: -90, z: 180
        this.transform.localEulerAngles = new Vector3(0.0f, -90.0f, 180.0f);
        this.transform.localScale       = Vector3.one * tdrcInterface.cnfg3d_scale;
        timeSliceCanvasRenderer.SetMesh(polygonMesh);

        // setup the mesh's material
        Material polygonMeshMat = new Material(Shader.Find("UI/Default"));

        //Material polygonMeshMat = new Material(Shader.Find("UI/Unlit/Transparent"));      // TODO - for some reason this shader does not load in the compiled application
        polygonMeshMat.color = polygonColor;
        timeSliceCanvasRenderer.SetMaterial(polygonMeshMat, null);

        // return created Mesh (for other elements to use)
        return(polygonMesh);
    }
Esempio n. 23
0
        private void MakeMesh(Vector2 lastHigh, Vector2 lastLow, Vector2 newHigh, Vector2 newLow)
        {
            Vector3[] vertices  = new Vector3[4];
            Vector2[] uv        = new Vector2[4];
            int[]     triangles = new int[6];

            vertices[0] = lastHigh;
            vertices[1] = lastLow;
            vertices[2] = newHigh;
            vertices[3] = newLow;

            uv[0] = lastHigh;
            uv[1] = lastLow;
            uv[2] = newHigh;
            uv[3] = newLow;

            triangles[0] = 0;
            triangles[1] = 2;
            triangles[2] = 1;
            triangles[3] = 1;
            triangles[4] = 2;
            triangles[5] = 3;

            Mesh mesh = new Mesh();

            mesh.vertices  = vertices;
            mesh.uv        = uv;
            mesh.triangles = triangles;

            GameObject mesh_go = new GameObject(name + " mesh", typeof(MeshFilter), typeof(MeshRenderer));

            Objects.Add(mesh_go);
            mesh_go.transform.SetParent(Graph_Container, false);
            mesh_go.GetComponent <MeshFilter>().mesh = mesh;

            CanvasRenderer cr = mesh_go.AddComponent <CanvasRenderer>();

            cr.SetMesh(mesh);
            mesh_go.GetComponent <CanvasRenderer>().SetMaterial(material, null);

            RectTransform rt = mesh_go.AddComponent <RectTransform>();

            rt.anchorMin = new Vector2(0, 0);
            rt.anchorMax = new Vector2(0, 0);
        }
Esempio n. 24
0
    /// <summary>
    /// Implementation to draw line chart based on the time-data series.
    /// Only draw if the count of time-data is at least 2.
    /// </summary>
    private void DrawLineChart()
    {
        for (int idx = 0; idx < controller.SeriesCount; idx++)
        {
            var dataCollection = controller.DataContainer.GetTimedDataCollection(idx);

            Vector3[] lines    = ChartUtils.CreateLinesFromData(dataCollection, chartHolder, controller.GetMinMaxOfAll());
            Mesh      lineMesh = ChartUtils.GenerateLineMesh(lines, 1.5f);

            string         name     = ChartUtils.NameGenerator(chartChildString, idx);
            GameObject     obj      = chartHolder.Find(name).gameObject;
            CanvasRenderer renderer = obj.GetComponent <CanvasRenderer>();

            renderer.Clear();
            renderer.SetMaterial(controller.materials[idx], null);
            renderer.SetMesh(lineMesh);
        }
    }
Esempio n. 25
0
    void Canvas_willRenderCanvases()
    {
        // canvas上にmeshGObjで指定したMeshを描画する。

        Mesh mesh = meshGObj.GetComponent <MeshFilter>().sharedMesh;

        if (material == null)
        {
            material = Canvas.GetDefaultCanvasMaterial();
            Debug.LogWarning("createMat");
        }

        CanvasRenderer canvasRenderer = GetComponent <CanvasRenderer>();

        canvasRenderer.Clear();
        canvasRenderer.SetMesh(mesh);
        canvasRenderer.SetMaterial(material, null);
    }
    public void SetMesh(Vector3 point1, Vector3 point2, Vector3 point3, Vector3 point4, Color color)
    {
        Init();

        points = new Vector2[]
        {
            point1, point2, point3, point4
        };

        var vectors = new Vector3[]
        {
            point1,
            point2,
            point3,
            point4
        };

        var uv = new Vector2[]
        {
            new Vector2(0, 0),
            new Vector2(1, 0),
            new Vector2(0, 1),
            new Vector2(1, 1),
        };

        var triangles = new int[]
        {
            0, 1, 3, 3, 2, 1
        };

        if (_mesh == null)
        {
            _mesh = new Mesh();
        }

        _mesh.Clear();
        _mesh.vertices  = vectors;
        _mesh.uv        = uv;
        _mesh.triangles = triangles;

        _canvasRenderer.SetMesh(_mesh);

        _material.color = color;
    }
Esempio n. 27
0
    public static int SetMesh(IntPtr l)
    {
        int result;

        try
        {
            CanvasRenderer canvasRenderer = (CanvasRenderer)LuaObject.checkSelf(l);
            Mesh           mesh;
            LuaObject.checkType <Mesh>(l, 2, out mesh);
            canvasRenderer.SetMesh(mesh);
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Esempio n. 28
0
    // Update is called once per frame
    void Update()
    {
        meshRenderer   = GetComponentInChildren <SkinnedMeshRenderer>();
        canvasRenderer = GetComponent <CanvasRenderer>();
        Mesh mesh = meshRenderer.sharedMesh;

        canvasRenderer.SetMesh(mesh);

        Material[] materials = meshRenderer.sharedMaterials;
        if (canvasRenderer.materialCount != materials.Length)
        {
            canvasRenderer.materialCount = materials.Length;
        }

        for (var i = 0; i < materials.Length; ++i)
        {
            canvasRenderer.SetMaterial(materials[i], i);
        }
    }
Esempio n. 29
0
    void ResetData()
    {
        if (m_canvasRenderer == null)
        {
            m_canvasRenderer = GetComponent <CanvasRenderer>();
        }

        if (m_canvasRenderer != null)
        {
            if (m_sourceRenderer == null)
            {
                m_sourceRenderer = GetComponent <Renderer>();
            }

            if (m_sourceRenderer != null)
            {
                Mesh meshData = null;
                if (m_sourceRenderer is SkinnedMeshRenderer)
                {
                    meshData = (m_sourceRenderer as SkinnedMeshRenderer).sharedMesh;
                }
                else if (m_sourceRenderer is MeshRenderer)
                {
                    MeshFilter meshFilter = GetComponent <MeshFilter>();
                    if (meshFilter != null)
                    {
                        meshData = meshFilter.sharedMesh;
                    }
                }

                if (meshData != null)
                {
                    m_canvasRenderer.SetMesh(meshData);

                    m_canvasRenderer.materialCount = m_sourceRenderer.sharedMaterials.Length;
                    for (int i = 0; i < m_canvasRenderer.materialCount; i++)
                    {
                        m_canvasRenderer.SetMaterial(m_sourceRenderer.sharedMaterials[i], i);
                    }
                }
            }
        }
    }
Esempio n. 30
0
        protected override void UpdateGeometry()
        {
            //IL_0059: Unknown result type (might be due to invalid IL or missing references)
            //IL_005e: Unknown result type (might be due to invalid IL or missing references)
            //IL_006b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0071: Unknown result type (might be due to invalid IL or missing references)
            //IL_0076: Unknown result type (might be due to invalid IL or missing references)
            //IL_007b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0089: Unknown result type (might be due to invalid IL or missing references)
            //IL_008a: Unknown result type (might be due to invalid IL or missing references)
            //IL_00a1: Unknown result type (might be due to invalid IL or missing references)
            //IL_00a2: Unknown result type (might be due to invalid IL or missing references)
            //IL_00a7: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c1: Unknown result type (might be due to invalid IL or missing references)
            //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
            //IL_00de: Unknown result type (might be due to invalid IL or missing references)
            //IL_00e4: Unknown result type (might be due to invalid IL or missing references)
            //IL_00e9: Unknown result type (might be due to invalid IL or missing references)
            CanvasRenderer canvasRenderer = this.get_canvasRenderer();
            Mesh           workerMesh     = Graphic.get_workerMesh();

            if (null == m_font || !m_font.isValid || string.IsNullOrEmpty(m_text))
            {
                workerMesh.Clear();
                m_computedWidth = 0f;
            }
            else
            {
                if (base.m_Material == null && m_tint != Color.get_white())
                {
                    Color val = m_color * m_tint;
                    m_font.BuildUIMesh(workerMesh, m_text, Color32.op_Implicit(val), m_alignment);
                    m_font.ChangeMeshColor(workerMesh, val, Color.op_Implicit(Color.get_white()));
                }
                else
                {
                    m_font.BuildUIMesh(workerMesh, m_text, Color32.op_Implicit(m_color), m_alignment);
                    m_font.ChangeMeshColor(workerMesh, m_color, Color.op_Implicit(m_tint));
                }
                m_computedWidth = m_font.lastComputedWidth;
            }
            canvasRenderer.SetMesh(workerMesh);
        }