Beispiel #1
0
    protected virtual void ErrorGUI(BuildStage[] allStages)
    {
        float     constMul = 6.8F;
        Texture2D success;
        Texture2D fail;

        int height = 10;

        int failStageIndex = ArrayUtility.IndexOf <BuildStage>(allStages,
                                                               failStage);

        int i = 0;

        while (i <= (int)lastStage)
        {
            bool   foundImage   = false;
            string resultString = "";

            if (i < failStageIndex)
            {
                success = (Texture2D)Resources.Load(
                    "icons/success",
                    typeof(Texture2D)
                    );

                if (success)
                {
                    GUI.DrawTexture(
                        new Rect(
                            errorTitles[i].Length * constMul,
                            height,
                            20,
                            20
                            ),
                        success
                        );
                    foundImage = true;
                }

                resultString = " SUCCEEDED";
            }

            else
            {
                fail = (Texture2D)Resources.Load(
                    "icons/false",
                    typeof(Texture2D)
                    );

                if (fail)
                {
                    GUI.DrawTexture(
                        new Rect(
                            errorTitles[i].Length * constMul,
                            height,
                            20,
                            20
                            ),
                        fail
                        );
                    foundImage = true;
                }

                resultString = " FAILED";
            }

            if (!foundImage)
            {
                if (resultString.Equals(" SUCCEEDED"))
                {
                    GUI.contentColor = Color.green;
                }
                else if (resultString.Equals(" FAILED"))
                {
                    GUI.contentColor = Color.red;
                }
                GUI.Label(new Rect(5, height, 590, 20), errorTitles[i] + " " +
                          resultString);

                GUI.contentColor = Color.black;
            }
            else
            {
                GUI.Label(new Rect(5, height, 590, 20), errorTitles[i]);
            }

            height += 40;
            i++;
        }

        GUI.Label(new Rect(10, height, 580, 200), "Error:\n" +
                  errorMessage, GUI.skin.textArea);

        if (GUI.Button(new Rect(530, 470, 60, 20), "Got it"))
        {
            instance.Close();
        }
    }