public SpawnGraph(MyEditorPanel graphP, int totalTime)
        {
            totalTimeToCount = totalTime;

            graphPanel = graphP;

            maxUnits = (int)SpawnTypes.GetMaximunNumberOfUnits(totalTimeToCount);
            totalUnitsAndUnitsPerSecForAllTypes = SpawnTypes.GetUnitsPerSec(totalTimeToCount);
            // Set up color array with random colors
            if (unitTypesColors == null)
            {
                SavedUnitTypeColorsArray savedCollorArrayObject = JsonLib.LoadGameData();
                if (savedCollorArrayObject != null && savedCollorArrayObject.colorArray.Length > 0)
                {
                    //Debug.Log("Unit types graph colors loaded from previous session");
                    unitTypesColors = savedCollorArrayObject.colorArray;
                }
                else
                {
                    //Debug.Log("No unit types graph colors loaded from previous session");
                    unitTypesColors = new Color[150];
                    for (int i = 0; i != unitTypesColors.Length; i++)
                    {
                        unitTypesColors[i]   = new Color(Random.Range(0, 0.9f), Random.Range(0, 0.9f), Random.Range(0, 0.9f), Random.Range(0, 0.9f));
                        unitTypesColors[i].a = 1;
                    }
                }
                JsonLib.SaveGameData(new SavedUnitTypeColorsArray(unitTypesColors));
            }
        }
 public static void IncDecGraphPanelRect(float x, float y, float w, float h)
 {
     graphPanel = new MyEditorPanel(new Rect(graphPanel.GetRect().x + x, graphPanel.GetRect().y + y, graphPanel.GetRect().width + w, graphPanel.GetRect().height + h));
     // inform scroll rects for new position
     spawnGraph.SetUpScrollRects(graphPanel.GetRect());
     spawnGraph.DrawUnitsPerSecGraph(graphPanel.GetRect());
 }
        private static MyEditorPanel SetUpGraphPanel()
        {
            Rect          rect   = new Rect(graphPanelXOffsetFromUnitTypes, graphOffsetFromProperties, graphPanelWidth, graphPanelHeight);
            MyEditorPanel graphP = new MyEditorPanel(rect);

            return(graphP);
        }
        void OnGUI()
        {
            // Draw "search" button and check if clicked
            DrawSearchSpawnersButton();
            // if initialized
            if (hasSearchedForSpawners)
            {
                if (searchButtonPressed)
                {
                    // if button pressed - re-initialize everything
                    graphPanel = SetUpGraphPanel();
                    SpawnTypes.SetAllTypes(totalSpawners);
                    numberOfTotalTypes = SpawnTypes.GetAllTypes().Count;
                    spawnGraph         = new SpawnGraph(graphPanel, totalTime + 1);
                    IncDecGraphPanelRect(0, 20 * numberOfTotalTypes, 0, 0);
                    SpawnerFields.SetTotalFoldoutsPerUnitType(numberOfTotalTypes);


                    searchButtonPressed = false;
                }
                // if show spawners data == true
                showSpawners = EditorGUILayout.Foldout(showSpawners, "Show spawners", EditorStyles.foldout);
                if (showSpawners && numberOfTotalTypes > 0)
                {
                    // Draw spawners and properties
                    SpawnerFields.DrawFormatedSpawnerFields();
                    // Draw graph's background
                    EditorGUI.DrawRect(graphPanel.GetRect(), graphPanelBackgroundColor);
                    // Draw the graph
                    spawnGraph.DrawUnitsPerSecGraph(graphPanel.GetRect());
                }
            }
            else
            {
                EditorGUILayout.LabelField("Press: Search spawners first!", EditorStyles.miniLabel);
            }
        }