示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        List <GameObject> rootObjects = new List <GameObject>();
        Scene             scene       = SceneManager.GetActiveScene();

        scene.GetRootGameObjects(rootObjects);

        // iterate root objects and do something
        for (int i = 0; i < rootObjects.Count; ++i)
        {
            GameObject g = rootObjects[i];
            UnityEngine.Component[] comps = g.GetComponents(typeof(PropertiesTest));
            string msg = "Nombre : " + g.name;
            if (comps.Length > 0)
            {
                PropertiesTest t = (PropertiesTest)comps[0];
                msg += " Id : " + t.Id;
            }
            msg += ". Valor contador = " + (++count);
            UnityEngine.Debug.Log(msg);
        }
    }
    private void RunTest(TestType testType, bool RunBaseLine = true)
    {
        PerformanceTest test       = null;
        int             iterations = int.Parse(inputField.text);

        switch (testType)
        {
        case TestType.Exception:
            test = new ExceptionTest {
                RunBaseline = RunBaseLine, Iterations = iterations
            };
            break;

        case TestType.Strings:
            test = new StringsTest {
                RunBaseline = RunBaseLine, Iterations = iterations
            };
            break;

        case TestType.Arrays:
            test = new ArraysTest {
                RunBaseline = RunBaseLine, Iterations = iterations
            };
            break;

        case TestType.Boxing:
            test = new BoxingTest {
                RunBaseline = RunBaseLine, Iterations = iterations
            };
            break;

        case TestType.ForForeach:
            test = new ForForeachTest {
                RunBaseline = RunBaseLine, Iterations = iterations
            };
            break;

        case TestType.Struct:
            test = new StructTest {
                RunBaseline = RunBaseLine, Iterations = iterations
            };
            break;

        case TestType.Memory:
            test = new MemoryTest {
                RunBaseline = RunBaseLine, Iterations = iterations
            };
            break;

        case TestType.Instantiation:
            test = new InstantiationTest {
                RunBaseline = RunBaseLine, Iterations = iterations
            };
            break;

        case TestType.Properties:
            test = new PropertiesTest {
                RunBaseline = RunBaseLine, Iterations = iterations
            };
            break;

        default:
            throw new ArgumentOutOfRangeException(nameof(testType), testType, null);
        }

        titleText.text       = test.Name;
        descriptionText.text = test.Description;
        var averageResult = test.Measure();

        lastPerformanceResult = averageResult;
        UpdatePerformanceResultUI();

        var(perA, perB, perC) = GetPercentageOfResult(averageResult);
        totalASlider.value    = perA;
        totalBSlider.value    = perB;
        totalCSlider.value    = perC;
    }