Example #1
0
 protected override void OnDisable()
 {
     base.OnDisable();
     if (emojiCanvasRenderer != null)
     {
         emojiCanvasRenderer.Clear();
     }
 }
Example #2
0
    void Start()

    {
        viewMesh      = new Mesh();
        viewMesh.name = "view Mesh";
        //viewMeshFilter.mesh = viewMesh;
        canvas.Clear();
        canvas.SetMesh(viewMesh);
        canvas.SetMaterial(material, 0);
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        Color32 color = new Color32(255, 0, 0, 255);

        //color = new Color32();
        UIVertex[] data = new UIVertex[] {
            new UIVertex()
            {
                position = new Vector3(0f, 0f, 0f), color = color
            },
            new UIVertex()
            {
                position = new Vector3(0f, 50f, 0f), color = color
            },
            new UIVertex()
            {
                position = new Vector3(50f, 50f, 50f), color = color
            },
            new UIVertex()
            {
                position = new Vector3(50f, 0f, 50f), color = color
            }
        };

        CanvasRenderer canvasRender = GetComponent <CanvasRenderer>();

        canvasRender.Clear();
        Material defaultMaterial = new Material(Shader.Find("UI/Default"));

        canvasRender.SetMaterial(defaultMaterial, null);
        canvasRender.SetVertices(data, data.Length);
        Debug.Log("start");
    }
Example #4
0
 public void ClearUIVertex()
 {
     if (uiVertex != null && uiVertex.Length > 0)
     {
         Array.Clear(uiVertex, 0, uiVertex.Length);
         m_inlineGraphicCanvasRenderer.Clear();
     }
 }
Example #5
0
 public void Draw()
 {
     canvasRender.Clear();
     canvasRender.SetMaterial(wallMaterial, null);
     canvasRender.GetMaterial().color = Color.white;
     canvasRender.SetVertices(vertlist);
     //Debug.Log("cout: " +  list.Count);
 }
Example #6
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();
            }
        }
    }
    protected override void _drawAxisBackground(List <UIVertex> pVertexList)
    {
        Material pMat = new Material(AxisMaterial);

        pMat.SetColor("_TintColor", MarginBackgroundColor);

        CanvasRenderer pCanvasRenderer = NGraphUtils.AddCanvasRenderer(mAxesBackgroundGo);

        pCanvasRenderer.Clear();
        pCanvasRenderer.SetMaterial(pMat, null);
        pCanvasRenderer.SetVertices(pVertexList);
    }
Example #8
0
        private void UpdateVisuals()
        {
            if (renderer == null)
            {
                return;
            }

            // Clear the canvas
            renderer.Clear();
            // Render the model
            Model?.Render(renderer, ActualWidth, ActualHeight);
        }
        protected virtual void DestroyMesh()
        {
            ClearMesh();
            Object.DestroyImmediate(_mesh);
            _mesh = null;

            CanvasRenderer v_canvasRenderer = GetComponent <CanvasRenderer>();

            if (v_canvasRenderer != null)
            {
                v_canvasRenderer.Clear();
            }
        }
Example #10
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>();
    }
    public override void setupGraphHierarchy()
    {
        base.setupGraphHierarchy();
        CanvasRenderer pCanvasRenderer = NGraphUtils.AddCanvasRenderer(mMeshesContainer);


        Material pMat = new Material(AxisMaterial);

        pMat.SetColor("_TintColor", GridLinesColorMajor);
        pCanvasRenderer.Clear();
        pCanvasRenderer.SetMaterial(pMat, null);

        NGraphUtils.DrawRect(new Rect(adjustPointX(-5) - (GridLinesThicknesMajor / 2f), adjustPointY(YRange.y), GridLinesThicknesMajor, adjustPointY(YRange.x) * 2), pCanvasRenderer);
    }
Example #12
0
    void MeshRenderTest()
    {
        CanvasRenderer cr   = meshTest.AddComponent <CanvasRenderer>();
        Mesh           mesh = new Mesh();

        mesh.vertices = new Vector3[] {
            new Vector3(0, 0, 0),
            new Vector3(0, 100, 0),
            new Vector3(100, 100, 0),
            new Vector3(100, 0, 0)
        };


        mesh.triangles = new int[] { 0, 1, 2, 2, 3, 0 };
//		mesh.colors = new Color[]{
//			Color.black,
//			Color.blue,
//			Color.cyan,
//			Color.gray
//		};
        cr.Clear();
        cr.SetMaterial(material, null);
//		cr.SetMesh (mesh);
        Vector3[] vertices  = mesh.vertices;
        int[]     triangles = mesh.triangles;
        Vector3[] normals   = mesh.normals;
        Vector2[] uv        = mesh.uv;
        UIVertex  vertex;
//		Debug.Log (uv.Length);
        List <UIVertex> vertexList = new List <UIVertex> ();

        for (int i = 0; i < triangles.Length; i++)
        {
            vertex = new UIVertex();
            int triangle = triangles[i];

            vertex.position = ((vertices[triangle] - mesh.bounds.center) * 1);
            vertex.uv0      = Vector2.one;
            vertex.normal   = Vector3.forward;

            vertexList.Add(vertex);

            if (i % 3 == 0)
            {
                vertexList.Add(vertex);
            }
        }
        cr.SetVertices(vertexList);
    }
 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();
 }
Example #14
0
    public static int Clear(IntPtr l)
    {
        int result;

        try
        {
            CanvasRenderer canvasRenderer = (CanvasRenderer)LuaObject.checkSelf(l);
            canvasRenderer.Clear();
            LuaObject.pushValue(l, true);
            result = 1;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
    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);
    }
Example #16
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);
        }
    }
Example #17
0
    public void AddValue(float val)
    {
        if (m_NormalizedGraphValues == null || m_NormalizedGraphValues.Length < m_Resolution)
        {
            m_NormalizedGraphValues = new float[m_Resolution];
        }

        for (int p = m_NormalizedGraphValues.Length - 1; p > 0; p--)
        {
            m_NormalizedGraphValues[p] = m_NormalizedGraphValues[p - 1];
        }

        m_NormalizedGraphValues[0] = val;

        UpdateVerts();

        pCanvasRenderer.Clear();
        pCanvasRenderer.SetVertices(pVertexList);
    }
    protected override void _drawMajorGridLine(Axis axis, int index, float r, GameObject pGridLineGameObject)
    {
        Material pMat = new Material(AxisMaterial);

        pMat.SetColor("_TintColor", GridLinesColorMajor);
        CanvasRenderer pCanvasRenderer = NGraphUtils.AddCanvasRenderer(pGridLineGameObject);

        pCanvasRenderer.Clear();
        pCanvasRenderer.SetMaterial(pMat, null);

        mXAxisTicks.Add(pCanvasRenderer);

        if (axis == Axis.X)
        {
            NGraphUtils.DrawRect(new Rect(adjustPointX(r) - (GridLinesThicknesMajor / 2f), adjustPointY(YRange.y), GridLinesThicknesMajor, adjustPointY(YRange.x) - adjustPointY(YRange.y)), pCanvasRenderer);
        }
        else if (axis == Axis.Y)
        {
            NGraphUtils.DrawRect(new Rect(adjustPointX(XRange.x), adjustPointY(r) + (GridLinesThicknesMajor / 2f), adjustPointX(XRange.y) - adjustPointX(XRange.x), -GridLinesThicknesMajor), pCanvasRenderer);
        }
    }
Example #19
0
 public void Clear()
 {
     _render.Clear();
 }