コード例 #1
0
ファイル: NGraph.cs プロジェクト: ErylKenner/bridgeinspection
 public virtual void setupGraphHierarchy()
 {
     if (mMeshesContainer == null)
     {
         mMeshesContainer = NGraphUtils.AddGameObject(gameObject, 0, "MeshesContainer");
     }
 }
コード例 #2
0
ファイル: NGraph.cs プロジェクト: ErylKenner/bridgeinspection
    protected void DrawAxes()
    {
        if (!Application.isPlaying || mMeshesContainer == null)
        {
            return;
        }

        if (mXRange == Vector2.zero)
        {
            return;
        }

        if (mYRange == Vector2.zero)
        {
            return;
        }

        AxesDrawAt.x = Mathf.Clamp(AxesDrawAt.x, XRange.x, XRange.y);
        AxesDrawAt.y = Mathf.Clamp(AxesDrawAt.y, YRange.x, YRange.y);

        Vector2 pTop    = adjustPoint(new Vector2(AxesDrawAt.x, YRange.y));
        Vector2 pBottom = adjustPoint(new Vector2(AxesDrawAt.x, YRange.x));
        Vector2 pLeft   = adjustPoint(new Vector2(XRange.x, AxesDrawAt.y));
        Vector2 pRight  = adjustPoint(new Vector2(XRange.y, AxesDrawAt.y));

        if (mAxesGo == null)
        {
            mAxesGo = NGraphUtils.AddGameObject(mMeshesContainer, AXES_LEVEL * LEVEL_STEP, "Axes");
            _addedAxesGameObject(mAxesGo);
            mXAxesGo = NGraphUtils.AddGameObject(mAxesGo, 0, "X Axes");
            _addedXAxisGameObject(mXAxesGo);
            mYAxesGo = NGraphUtils.AddGameObject(mAxesGo, 0, "Y Axes");
            _addedYAxisGameObject(mYAxesGo);
        }

        Rect x = new Rect(pLeft.x, AxesThickness / 2 + pLeft.y, pRight.x - pLeft.x, -AxesThickness);
        Rect y = new Rect(pTop.x - AxesThickness / 2, pTop.y, AxesThickness, -(pTop.y - pBottom.y));


        float z1 = mAxesGo.transform.localPosition.z;
        float z2 = mXAxesGo.transform.localPosition.z;
        float z3 = mYAxesGo.transform.localPosition.z;

        this._drawAxes(x, y);

        mAxesGo.transform.localPosition  = new Vector3(0, 0, z1);
        mXAxesGo.transform.localPosition = new Vector3(0, 0, z2);
        mYAxesGo.transform.localPosition = new Vector3(0, 0, z3);
    }
コード例 #3
0
    public int addDataLabel(float xValue, string label = null)
    {
        GameObject      pLabelGo = NGraphUtils.AddGameObject(mDataLabelContainerGo, 0, "Plot Label - " + mDataLabels.Count);
        dataLabelStruct str;

        str.xValue  = xValue;
        str.gameObj = pLabelGo;
        str.text    = label;

        mDataLabels.Add(str);
        int pos = mDataLabels.Count - 1;

        drawDataLabel(mDataLabels[pos]);
        return(pos);
    }
コード例 #4
0
ファイル: NGraph.cs プロジェクト: ErylKenner/bridgeinspection
    /** \brief  Add a data series type to the graph.
     *
     *  T must be a child of NGraphDataSeries.
     * \param name Name of this plot.
     * \param pPlotColor Default color for this plot.
     * \param pMaterial Optional default material override for this plot.  Pass null for NGraph default.
     */
    public T addDataSeries <T>(string name, Color pPlotColor, Material pMaterial = null) where T : NGraphDataSeries
    {
        setupGraphHierarchy();
        GameObject pGameObject = NGraphUtils.AddGameObject(mMeshesContainer, PLOT_START_LEVEL * LEVEL_STEP, "Data Series - " + name);

        newDataSeriesGameObject(pGameObject);

        T pNGraphDataSeries = pGameObject.AddComponent <T>();

        if (pMaterial == null)
        {
            pNGraphDataSeries.PlotMaterial = DefaultPlotMaterial;
        }
        else
        {
            pNGraphDataSeries.PlotMaterial = pMaterial;
        }
        pNGraphDataSeries.PlotColor = pPlotColor;

        mDataSeries.Add(pNGraphDataSeries);

        GameObject pDataLabelContainer = NGraphUtils.AddGameObject(DataLabelTopContainer, -1, "\"" + name + "\"");

        newDataSeriesDataLabelContainerGameObject(pDataLabelContainer);

        List <GameObject> pChildGos = pNGraphDataSeries.setup(
            this,
            pGameObject,
            (GameObject pLabelGo, Vector3 pValue, string text) =>
        {
            if (text == null)
            {
                text = pValue.y.ToString();
            }
            Vector3 pDataLabelPosition = adjustPoint(new Vector2(pValue.x, pValue.y));
            AddDataSeriesLabel(pLabelGo, pDataLabelPosition, pValue, text);
        },
            pDataLabelContainer
            );

        newDataSeriesChildGameObjects(pChildGos);
        pNGraphDataSeries.DrawSeries();

        return(pNGraphDataSeries);
    }
コード例 #5
0
ファイル: NGraph.cs プロジェクト: ErylKenner/bridgeinspection
    protected void DrawGrid()
    {
        // Make sure it exists
        if (mGridContainer == null)
        {
            mGridContainer = NGraphUtils.AddGameObject(mMeshesContainer, LEVEL_STEP * 2, "GridContainer");
            _addedGridContainer(mGridContainer);
        }

        // Clear the children
        for (int i = 0; i < mGridContainer.transform.childCount; i++)
        {
            Destroy(mGridContainer.transform.GetChild(i).gameObject);
        }

        int index = 0;

        if (GridLinesSeparationMajor.x > 0)
        {
            for (float r = XRange.x; r <= XRange.y; r += GridLinesSeparationMajor.x)
            {
                GameObject pGridLineGo = NGraphUtils.AddGameObject(mGridContainer, 0, "Major X Grid Line - " + r);
                this._drawMajorGridLine(Axis.X, index++, r, pGridLineGo);
            }
        }

        index = 0;
        if (GridLinesSeparationMajor.y > 0)
        {
            for (float r = YRange.x; r <= YRange.y; r += GridLinesSeparationMajor.y)
            {
                GameObject pGridLineGo = NGraphUtils.AddGameObject(mGridContainer, 0, "Major Y Grid Line - " + r);
                this._drawMajorGridLine(Axis.Y, index++, r, pGridLineGo);
            }
        }

        float z = mGridContainer.transform.localPosition.z;

        mGridContainer.transform.localPosition = new Vector3(0, 0, z);
    }
コード例 #6
0
    protected void drawMarker(Vector2 pDataPoint, int dataPointIndex)
    {
        Mesh           pMesh           = null;
        GameObject     pMarkerGo       = NGraphUtils.AddGameObject(mGameObject, NGraph.LEVEL_STEP, "Marker - " + dataPointIndex);
        CanvasRenderer pCanvasRenderer = null;

        if (mGraph.UnityGui)
        {
            pCanvasRenderer = NGraphUtils.AddCanvasRenderer(pMarkerGo);
            Material pMat = new Material(PlotMaterial);
            pMat.SetColor("_TintColor", mMarkerColor);
            pMat.SetVector("_Clipping", new Vector4(mClipping.x, mClipping.y, mClipping.z, mClipping.w));

            pCanvasRenderer.SetMaterial(pMat, null);
        }
        else
        {
            NGraphUtils.AddMesh(pMarkerGo, out mMeshRenderer, out pMesh);
            mMeshRenderer.material = PlotMaterial;
            mMeshRenderer.material.SetColor("_TintColor", mMarkerColor);
            mMeshRenderer.material.SetVector("_Clipping", new Vector4(mClipping.x, mClipping.y, mClipping.z, mClipping.w));
        }
        mMarkerGos.Add(pMarkerGo);

        List <Vector3> pVertices  = new List <Vector3>();
        List <Vector2> pUvs       = new List <Vector2>();
        List <int>     pTriangles = new List <int>();

        switch (MarkersStyle)
        {
        case MarkerStyle.Box:
        {
            /*
             * c      d
             *
             *
             * b      a
             */

            pVertices.Add(new Vector3(mMarkerWeight / 2 + pDataPoint.x, -mMarkerWeight / 2 + pDataPoint.y, 0));
            pVertices.Add(new Vector3(-mMarkerWeight / 2 + pDataPoint.x, -mMarkerWeight / 2 + pDataPoint.y, 0));
            pVertices.Add(new Vector3(-mMarkerWeight / 2 + pDataPoint.x, mMarkerWeight / 2 + pDataPoint.y, 0));
            pVertices.Add(new Vector3(mMarkerWeight / 2 + pDataPoint.x, mMarkerWeight / 2 + pDataPoint.y, 0));
            pUvs.Add(new Vector2(0, 0));
            pUvs.Add(new Vector2(1, 0));
            pUvs.Add(new Vector2(0, 1));
            pUvs.Add(new Vector2(1, 1));

            pTriangles.Add(0);
            pTriangles.Add(1);
            pTriangles.Add(2);

            pTriangles.Add(2);
            pTriangles.Add(3);
            pTriangles.Add(0);

            break;
        }

        case MarkerStyle.Triangle:
        {
            /*
             *    c
             *
             *
             * a      b
             */

            pVertices.Add(new Vector3(pDataPoint.x, pDataPoint.y + mMarkerWeight / 2, 0));
            pVertices.Add(new Vector3(mMarkerWeight / 2 + pDataPoint.x, -mMarkerWeight / 2 + pDataPoint.y, 0));
            pVertices.Add(new Vector3(-mMarkerWeight / 2 + pDataPoint.x, -mMarkerWeight / 2 + pDataPoint.y, 0));
            pUvs.Add(new Vector2(0, 0));
            pUvs.Add(new Vector2(1, 0));
            pUvs.Add(new Vector2(0.5f, 1));
            if (mGraph.UnityGui)
            {
                pVertices.Add(new Vector3(-mMarkerWeight / 2 + pDataPoint.x, -mMarkerWeight / 2 + pDataPoint.y, 0));
                pUvs.Add(new Vector2(0.5f, 1));
            }

            pTriangles.Add(0);
            pTriangles.Add(1);
            pTriangles.Add(2);

            break;
        }
        }

        if (mGraph.UnityGui)
        {
            List <UIVertex> vertices = new List <UIVertex>(pVertices.Count);
            for (int i = 0; i < pVertices.Count; i++)
            {
                UIVertex pVertex = new UIVertex();
                pVertex.position = pVertices[i];
                pVertex.uv0      = pUvs[i];
                vertices.Add(pVertex);
            }
            pCanvasRenderer.SetVertices(vertices);
        }
        else
        {
            pMesh.vertices  = pVertices.ToArray();
            pMesh.uv        = pUvs.ToArray();
            pMesh.triangles = pTriangles.ToArray();
        }
    }
コード例 #7
0
    public override void DrawSeries()
    {
        if (mGameObject == null || mData == null)
        {
            return;
        }

        base.DrawSeries();
        clearMarkers();
        int meshCount = mData.Count;

        if (mPlotStyle == Style.Line)
        {
            meshCount = 1;
        }
        clearMeshes(meshCount);
        clearCanvasRenderers(meshCount);

        List <Vector3> pVertices  = new List <Vector3>();
        List <Vector2> pUvs       = new List <Vector2>();
        List <int>     pTriangles = new List <int>();

        Mesh           pMesh;
        CanvasRenderer pCanvasRenderer;

        if (!mGraph.UnityGui && mMeshes == null)
        {
            mMeshes = new List <KeyValuePair <GameObject, Mesh> >();
        }
        else if (mGraph.UnityGui && mCanvasRenderers == null)
        {
            mCanvasRenderers = new List <KeyValuePair <GameObject, CanvasRenderer> >();
        }

        Vector2 pZero = mGraph.adjustPoint(Vector2.zero);

        for (int i = 0; i < mData.Count; ++i)
        {
            Vector2 pDataPoint = mData[i];
            pDataPoint = mGraph.adjustPoint(pDataPoint);

            if (MarkersStyle != MarkerStyle.None)
            {
                drawMarker(pDataPoint, i);
            }

            if (mPlotStyle == Style.Line && i == 0)
            {
                continue;
            }

            if (mPlotStyle == Style.Line)
            {
                Vector2 pPrevDataPoint = mData[i - 1];
                NGraphUtils.addSegment(mGraph.adjustPoint(pPrevDataPoint), pDataPoint, PlotThickness, pVertices, pUvs, pTriangles, mGraph.UnityGui);
            }
            else if (mPlotStyle == Style.Bar)
            {
                if (mGraph.UnityGui)
                {
                    if (i >= mCanvasRenderers.Count)
                    {
                        GameObject pChildBarGo = NGraphUtils.AddGameObject(mGameObject, 0, "Bar - " + i);
                        pCanvasRenderer = NGraphUtils.AddCanvasRenderer(pChildBarGo);
                        mCanvasRenderers.Add(new KeyValuePair <GameObject, CanvasRenderer>(pChildBarGo, pCanvasRenderer));
                    }
                    else
                    {
                        pCanvasRenderer = mCanvasRenderers[i].Value;
                    }

                    Material pMat = new Material(PlotMaterial);
                    pMat.SetColor("_TintColor", PlotColor);
                    pMat.SetVector("_Clipping", new Vector4(mClipping.x, mClipping.y, mClipping.z, mClipping.w));

                    pCanvasRenderer.SetMaterial(pMat, null);

                    float h   = pDataPoint.y - pZero.y;
                    float top = pZero.y;
                    NGraphUtils.DrawRect(new Rect(-mPlotThickness / 2 + pDataPoint.x, top, mPlotThickness, h), pCanvasRenderer);
                }
                else
                {
                    if (i >= mMeshes.Count)
                    {
                        GameObject pChildBarGo = NGraphUtils.AddGameObject(mGameObject, 0, "Bar - " + i);
                        NGraphUtils.AddMesh(pChildBarGo, out mMeshRenderer, out pMesh);
                        mMeshes.Add(new KeyValuePair <GameObject, Mesh>(pChildBarGo, pMesh));
                        mMeshRenderer.material = new Material(PlotMaterial);
                        mMeshRenderer.material.SetColor("_TintColor", PlotColor);
                        mMeshRenderer.material.SetVector("_Clipping", new Vector4(mClipping.x, mClipping.y, mClipping.z, mClipping.w));
                    }
                    else
                    {
                        pMesh = mMeshes[i].Value;
                    }

                    pMesh.Clear();
                    NGraphUtils.DrawRect(new Rect(-mPlotThickness / 2 + pDataPoint.x, pZero.y, mPlotThickness, pDataPoint.y - pZero.y), pMesh);
                }
            }
        }

        if (mPlotStyle == Style.Line)
        {
            if (mGraph.UnityGui)
            {
                if (mCanvasRenderers.Count == 0)
                {
                    GameObject pChildBarGo = NGraphUtils.AddGameObject(mGameObject, 0, "Line");
                    pCanvasRenderer = NGraphUtils.AddCanvasRenderer(pChildBarGo);
                    mCanvasRenderers.Add(new KeyValuePair <GameObject, CanvasRenderer>(pChildBarGo, pCanvasRenderer));
                }
                else
                {
                    pCanvasRenderer = mCanvasRenderers[0].Value;
                }

                Vector3[] e = new Vector3[4];
                mGraph.GetComponent <RectTransform>().GetWorldCorners(e);

                Material pMat = new Material(PlotMaterial);
                pMat.SetColor("_TintColor", PlotColor);
                pMat.SetVector("_Clipping", new Vector4(mClipping.x, mClipping.y, mClipping.z, mClipping.w));

                pCanvasRenderer.SetMaterial(pMat, null);
                List <UIVertex> vertices = new List <UIVertex>(pVertices.Count);
                for (int i = 0; i < pVertices.Count; i++)
                {
                    UIVertex pVertex = new UIVertex();
                    pVertex.position = pVertices[i];
                    pVertex.uv0      = pUvs[i];
                    vertices.Add(pVertex);
                }
                pCanvasRenderer.SetVertices(vertices);
            }
            else
            {
                if (mMeshes.Count == 0)
                {
                    GameObject pChildBarGo = NGraphUtils.AddGameObject(mGameObject, 0, "Line");
                    NGraphUtils.AddMesh(pChildBarGo, out mMeshRenderer, out pMesh);
                    mMeshes.Add(new KeyValuePair <GameObject, Mesh>(pChildBarGo, pMesh));
                    mMeshRenderer.material = new Material(PlotMaterial);
                    mMeshRenderer.material.SetColor("_TintColor", PlotColor);
                    mMeshRenderer.material.SetVector("_Clipping", new Vector4(mClipping.x, mClipping.y, mClipping.z, mClipping.w));
                }
                else
                {
                    pMesh = mMeshes[0].Value;
                }

                pMesh.Clear();
                pMesh.vertices  = pVertices.ToArray();
                pMesh.uv        = pUvs.ToArray();
                pMesh.triangles = pTriangles.ToArray();
            }
        }

        // Draw data labels if available
        foreach (dataLabelStruct labelInfo in mDataLabels)
        {
            drawDataLabel(labelInfo);
        }
    }
コード例 #8
0
ファイル: NGraph.cs プロジェクト: ErylKenner/bridgeinspection
    protected void DrawAxisBackground()
    {
        if (mAxesBackgroundGo == null)
        {
            mAxesBackgroundGo = NGraphUtils.AddGameObject(mMeshesContainer, BACKGROUND_LEVEL * LEVEL_STEP, "Axes Background");
        }

        /*
         * a  b&m       n&i j
         *    p          o
         *
         *
         *
         *               l  k
         *     e            f
         * c  d&g           h
         *
         */
        Rect    pRect = mRectTransform.rect;
        Vector3 a     = new Vector3(pRect.xMin, pRect.yMax, 0);
        Vector3 b     = new Vector3(pRect.xMin + Margin.x, pRect.yMax, 0);
        Vector3 c     = new Vector3(pRect.xMin, pRect.yMin, 0);
        Vector3 d     = new Vector3(pRect.xMin + Margin.x, pRect.yMin, 0);

        Vector3 e = new Vector3(pRect.xMin + Margin.x, pRect.yMin + Margin.y, 0);
        Vector3 f = new Vector3(pRect.xMax, pRect.yMin + Margin.y, 0);
        Vector3 g = new Vector3(pRect.xMin + Margin.x, pRect.yMin, 0);
        Vector3 h = new Vector3(pRect.xMax, pRect.yMin, 0);

        Vector3 i = new Vector3(pRect.xMax - Margin.z, pRect.yMax, 0);
        Vector3 j = new Vector3(pRect.xMax, pRect.yMax, 0);
        Vector3 k = new Vector3(pRect.xMax, pRect.yMin + Margin.y, 0);
        Vector3 l = new Vector3(pRect.xMax - Margin.z, pRect.yMin + Margin.y, 0);

        Vector3 m = new Vector3(pRect.xMin + Margin.x, pRect.yMax, 0);
        Vector3 n = new Vector3(pRect.xMax - Margin.z, pRect.yMax, 0);
        Vector3 o = new Vector3(pRect.xMax - Margin.z, pRect.yMax - Margin.w, 0);
        Vector3 p = new Vector3(pRect.xMin + Margin.x, pRect.yMax - Margin.w, 0);

        List <UIVertex> pList     = new List <UIVertex>(6);
        UIVertex        pUIVertex = new UIVertex();


        pUIVertex.position = a;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);

        pUIVertex.position = b;
        pUIVertex.uv0      = new Vector2(0.5f, 1);
        pList.Add(pUIVertex);

        pUIVertex.position = d;
        pUIVertex.uv0      = new Vector2(0.5f, 0.5f);
        pList.Add(pUIVertex);

        pUIVertex.position = c;
        pUIVertex.uv0      = new Vector2(0, 0);
        pList.Add(pUIVertex);


        pUIVertex.position = e;
        pUIVertex.uv0      = new Vector2(1, 0.5f);
        pList.Add(pUIVertex);

        pUIVertex.position = f;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);

        pUIVertex.position = h;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);

        pUIVertex.position = g;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);


        pUIVertex.position = i;
        pUIVertex.uv0      = new Vector2(1, 0.5f);
        pList.Add(pUIVertex);

        pUIVertex.position = j;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);

        pUIVertex.position = k;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);

        pUIVertex.position = l;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);


        pUIVertex.position = m;
        pUIVertex.uv0      = new Vector2(1, 0.5f);
        pList.Add(pUIVertex);

        pUIVertex.position = n;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);

        pUIVertex.position = o;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);

        pUIVertex.position = p;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);


        float z = mAxesBackgroundGo.transform.localPosition.z;

        this._drawAxisBackground(pList);
        mAxesBackgroundGo.transform.localPosition = new Vector3(0, 0, z);
    }
コード例 #9
0
ファイル: NGraph.cs プロジェクト: ErylKenner/bridgeinspection
    protected virtual void DrawAxisTicks()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        if (mAxesGo == null)
        {
            return;
        }

        AxesDrawAt.x = Mathf.Clamp(AxesDrawAt.x, XRange.x, XRange.y);
        AxesDrawAt.y = Mathf.Clamp(AxesDrawAt.y, YRange.x, YRange.y);

        if (mAxesLabelContainerGo == null)
        {
            mAxesLabelContainerGo = NGraphUtils.AddGameObject(gameObject, 0, "Axes Label Container");
            addedAxesLabelContainer();
        }

        int numTicks = XNumberOfTicks;

        if (XTickStyle == TickStyle.EvenSpaceLowAndHigh)
        {
            numTicks--;
        }
        float step = (mXRange.y - mXRange.x) / numTicks;

        if (XTickStyle == TickStyle.EvenSpaceLowAndHigh)
        {
            numTicks++;
        }
        for (int i = 0; i < numTicks; i++)
        {
            GameObject pTickGo = NGraphUtils.AddGameObject(mXAxesGo, AXES_LEVEL * LEVEL_STEP, "Tick X - " + i);

            float val = step * (i + 1);
            if (XTickStyle == TickStyle.EvenSpace)
            {
                val -= step / 2;
            }
            else if (XTickStyle == TickStyle.EvenSpaceLow || XTickStyle == TickStyle.EvenSpaceLowAndHigh)
            {
                val -= step;
            }
            Vector2 pPoint = new Vector2(val + XRange.x, AxesDrawAt.y);
            pPoint = adjustPoint(pPoint);

            Vector3 pPosition = pTickGo.transform.localPosition;
            pPosition.x += pPoint.x;
            pPosition.y += pPoint.y;
            pTickGo.transform.localPosition = pPosition;

            if (DrawXLabel)
            {
                GameObject pTickLabelGo = NGraphUtils.AddGameObject(mAxesLabelContainerGo.gameObject, AXES_LEVEL * LEVEL_STEP, "Tick Label X - " + i);
                pPosition.y -= 4;

                AddAxisLabel(Axis.X, pTickLabelGo, pPosition, val + XRange.x);
            }
            this._drawAxisTick(Axis.X, i, pTickGo);
        }

        numTicks = YNumberOfTicks;
        if (YTickStyle == TickStyle.EvenSpaceLowAndHigh)
        {
            numTicks--;
        }
        step = (mYRange.y - mYRange.x) / numTicks;
        if (YTickStyle == TickStyle.EvenSpaceLowAndHigh)
        {
            numTicks++;
        }
        for (int i = 0; i < numTicks; i++)
        {
            GameObject pTickGo = NGraphUtils.AddGameObject(mYAxesGo, AXES_LEVEL * LEVEL_STEP, "Tick Y - " + i);

            float val = step * (i + 1);
            if (YTickStyle == TickStyle.EvenSpace)
            {
                val -= step / 2;
            }
            else if (YTickStyle == TickStyle.EvenSpaceLow || YTickStyle == TickStyle.EvenSpaceLowAndHigh)
            {
                val -= step;
            }
            Vector2 pPoint = new Vector2(AxesDrawAt.x, val + YRange.x);
            pPoint = adjustPoint(pPoint);

            Vector3 pPosition = pTickGo.transform.localPosition;
            pPosition.x += pPoint.x;
            pPosition.y += pPoint.y;
            pTickGo.transform.localPosition = pPosition;

            if (DrawYLabel)
            {
                GameObject pTickLabelGo = NGraphUtils.AddGameObject(mAxesLabelContainerGo.gameObject, 0, "Tick Label Y - " + i);
                pPosition.x -= 6;

                AddAxisLabel(Axis.Y, pTickLabelGo, pPosition, val + YRange.x);
            }

            this._drawAxisTick(Axis.Y, i, pTickGo);
        }
    }
コード例 #10
0
ファイル: NGraph.cs プロジェクト: ErylKenner/bridgeinspection
    public virtual void DrawPlotBackground()
    {
        List <Transform> children = new List <Transform>();

        for (int i = mMeshesContainer.transform.childCount - 1; i >= 0; i--)
        {
            Transform child = mMeshesContainer.transform.GetChild(i);
            children.Add(child);
            child.SetParent(null);
        }

        if (mPlotBackgroundGo == null)
        {
            mPlotBackgroundGo = NGraphUtils.AddGameObject(mMeshesContainer, 10, "Plot Background");
        }

        foreach (Transform child in children)
        {
            child.SetParent(mMeshesContainer.transform);
        }

        List <UIVertex> pList = new List <UIVertex>(4);

        /*
         * 1a       2b
         *
         *
         *
         * 0c       3d
         *
         */
        Rect    pPlotArea = PlotArea;
        Vector3 a         = new Vector3(pPlotArea.xMin, pPlotArea.yMax, 0);
        Vector3 b         = new Vector3(pPlotArea.xMax, pPlotArea.yMax, 0);
        Vector3 c         = new Vector3(pPlotArea.xMin, pPlotArea.yMin, 0);
        Vector3 d         = new Vector3(pPlotArea.xMax, pPlotArea.yMin, 0);

        UIVertex pUIVertex = new UIVertex();

        pUIVertex.position = c;
        pUIVertex.uv0      = new Vector2(1, 1);
        pList.Add(pUIVertex);

        pUIVertex.position = a;
        pUIVertex.uv0      = new Vector2(0, 0);
        pList.Add(pUIVertex);

        pUIVertex.position = b;
        pUIVertex.uv0      = new Vector2(0, 1);
        pList.Add(pUIVertex);


        pUIVertex.position = d;
        pUIVertex.uv0      = new Vector2(1, 0);
        pList.Add(pUIVertex);

        float z = mPlotBackgroundGo.transform.localPosition.z;

        this._drawPlotBackground(pList);
        mPlotBackgroundGo.transform.localPosition = new Vector3(0, 0, z);
    }