Exemple #1
0
    static void createRadarGraph()
    {
        GameObject     graphGO = GameObject.Instantiate(baseAxis) as GameObject;
        WMG_Axis_Graph graph   = graphGO.GetComponent <WMG_Axis_Graph>();

        graph.changeSpriteParent(graphGO, theCanvas);
        graphGO.name = "RadarGraph";
        graph.changeSpriteSize(graphGO, 405, 280);
        graph.changeSpritePositionTo(graphGO, new Vector3(0, 0, 0));
        graph.paddingTopBottom = new Vector2(graph.paddingTopBottom.x, 60);
        Object newLegend = AssetDatabase.LoadAssetAtPath("Assets/Graph_Maker/Prefabs/Misc/Legend-None.prefab", typeof(GameObject));

        if (newLegend != null)
        {
            graph.legendPrefab = newLegend;
        }

        graph.changeSpriteColor(graph.graphBackground, Color.black);
        graph.SetActive(graph.xAxis, false);
        graph.SetActive(graph.yAxis, false);
        graph.axesType = WMG_Axis_Graph.axesTypes.CENTER;
        DestroyImmediate(graph.lineSeries[1]);
        graph.lineSeries.RemoveAt(1);
        DestroyImmediate(graph.lineSeries[0]);
        graph.lineSeries.RemoveAt(0);

        graph.yAxisMinValue         = -100;
        graph.yAxisMaxValue         = 100;
        graph.xAxisMinValue         = -100;
        graph.xAxisMaxValue         = 100;
        graph.yAxisNumTicks         = 5;
        graph.autoAnimationsEnabled = false;
        graph.hideXLabels           = true;
        graph.hideYLabels           = true;
        graph.hideXTicks            = true;
        graph.hideYTicks            = true;

        WMG_Radar_Graph radar = graphGO.AddComponent <WMG_Radar_Graph>();

        radar.theGraph            = graph;
        radar.randomData          = true;
        radar.numPoints           = 5;
        radar.offset              = new Vector2(-3, -20);
        radar.degreeOffset        = 90;
        radar.radarMaxVal         = 100;
        radar.numGrids            = 7;
        radar.gridLineWidth       = 0.5f;
        radar.gridColor           = new Color32(125, 125, 125, 255);
        radar.numDataSeries       = 1;
        radar.dataSeriesLineWidth = 1;
        List <Color> radarColors = new List <Color>();

        radarColors.Add(new Color32(0, 255, 180, 255));
        radarColors.Add(new Color32(210, 0, 255, 255));
        radarColors.Add(new Color32(160, 210, 65, 255));
        radar.dataSeriesColors = radarColors;
        radar.labelsColor      = Color.white;
        radar.labelsOffset     = 26;
        radar.fontSize         = 14;
        List <string> labelStrings = new List <string>();

        labelStrings.Add("Strength");
        labelStrings.Add("Speed");
        labelStrings.Add("Agility");
        labelStrings.Add("Magic");
        labelStrings.Add("Defense");
        radar.labelStrings = labelStrings;

        graph.pointPrefabs.Add(AssetDatabase.LoadAssetAtPath("Assets/Graph_Maker/Prefabs/Nodes/TextNode.prefab", typeof(GameObject)));
        UnityEditorInternal.ComponentUtility.MoveComponentUp(radar);

        graph.hideYGrid = true;
        graph.hideXGrid = true;
    }
Exemple #2
0
 public void UpdateHidePoints()
 {
     if (hidePointsChanged)
     {
         // Series points
         for (int i = 0; i < pointValues.Count; i++)
         {
             if (hidePoints)
             {
                 theGraph.SetActive(points[i], false);
             }
             else
             {
                 theGraph.SetActive(points[i], true);
             }
         }
         // Legend point
         if (hidePoints)
         {
             theGraph.SetActive(legendEntryNode, false);
         }
         else
         {
             theGraph.SetActive(legendEntryNode, true);
         }
     }
 }