Exemplo n.º 1
0
    public void Benchmark_ChildNotation_TrickyDeepScene()
    {
        SuperFindTestHelpers.CreateTrickyDeepScene();

        var watch = new Stopwatch();

        watch.Reset();
        watch.Start();
        for (int i = 0; i < REPS; i++)
        {
            SuperFind.Find("Root Child");
        }
        watch.Stop();
        var superFindTime = watch.Elapsed;

        watch.Reset();
        watch.Start();
        for (int i = 0; i < REPS; i++)
        {
            GameObject.Find("Root/Middle/Child");
        }
        watch.Stop();
        var nativeTime = watch.Elapsed;

        Debug.Log("Benchmark_ChildNotation_TrickyDeepScene: Time for GameObject.Find = " + nativeTime.TotalMilliseconds + "ms. Time for SuperFind.Find = " +
                  superFindTime.TotalMilliseconds + "ms for " + REPS + " reps.");
    }
Exemplo n.º 2
0
    public void FindsBySiblingNotation_SiblingScene_first()
    {
        var target = SuperFindTestHelpers.CreateSiblingScene(6, 0);

        var result = SuperFind.Find("Child(Clone):first");

        Assert.AreSame(target, result);
    }
Exemplo n.º 3
0
    public void CannotFind()
    {
        SuperFindTestHelpers.CreateSceneWithRoot();

        var result = SuperFind.Find("Wrong");

        Assert.IsNull(result);
    }
Exemplo n.º 4
0
    public void FindsByChildNotaton_TrickyDeepScene()
    {
        SuperFindTestHelpers.CreateTrickyDeepScene();

        var result = SuperFind.Find("Root Child");

        Assert.AreEqual("Child", result.name);
    }
Exemplo n.º 5
0
    public void FindsByExactName_DeepScene()
    {
        SuperFindTestHelpers.CreateDeepScene();

        var result = SuperFind.Find("Child");

        Assert.AreEqual("Child", result.name);
    }
Exemplo n.º 6
0
    public void FindsByName_WithSpaces()
    {
        SuperFindTestHelpers.CreateSceneWithSpacesInName();

        var result = SuperFind.Find("\"Child With Spaces\"");

        Assert.AreEqual("Child With Spaces", result.name);
    }
Exemplo n.º 7
0
    public void FindsByExactName_Root()
    {
        SuperFindTestHelpers.CreateSceneWithRoot();

        var result = SuperFind.Find("Root");

        Assert.AreEqual("Root", result.name);
    }
Exemplo n.º 8
0
    public void FindsBySiblingNotation_MultipleSiblingsScene_5()
    {
        var target = SuperFindTestHelpers.CreateMultipleSetsofSiblingsScene(3, 6, 5);

        var result = SuperFind.Find("Child(Clone):5");

        Assert.AreSame(target, result);
    }
Exemplo n.º 9
0
    public void FindsBySiblingNotation_SiblingScene_Index5()
    {
        var target = SuperFindTestHelpers.CreateSiblingScene(6, 5);

        var result = SuperFind.Find("Child(Clone):5");

        Assert.AreEqual(target, result);
    }
Exemplo n.º 10
0
    public void FindsByExactName_Root_Inactive()
    {
        SuperFindTestHelpers.CreateSceneWithRoot();
        GameObject.Find("Root").SetActive(false);

        var result = SuperFind.Find("Root");

        Assert.AreEqual("Root", result.name);
    }
Exemplo n.º 11
0
    public void FindsByChildNotaton_DeepScene_Inactive()
    {
        SuperFindTestHelpers.CreateDeepScene();
        GameObject.Find("Child").SetActive(false);
        GameObject.Find("Root").SetActive(false);

        var result = SuperFind.Find("Root Child");

        Assert.AreEqual("Child", result.name);
    }
Exemplo n.º 12
0
    private void OnGUI()
    {
        _input = GUILayout.TextField(_input);

        if (GUILayout.Button("SuperFind.Find"))
        {
            GameObject found = SuperFind.Find(_input);
            if (found != null)
            {
                Selection.SetActiveObjectWithContext(found, null);
            }
        }

        if (GUILayout.Button("SuperFind.FindAll"))
        {
            GameObject[] found = SuperFind.FindAll(_input);
            if (found.Length != 0)
            {
                Selection.objects = found;
            }
        }
    }