Beispiel #1
0
    void Start()
    {
        var mesh = this.GetComponent<MeshFilter>().mesh;
        _batcher = new Batcher(mesh, this.GetComponent<Camera>());

        AtlasBuilder atlasBuilder = new AtlasBuilder();

        var watch = new System.Diagnostics.Stopwatch();
        watch.Start();

        foreach(char c in "abcdefghijklmnopqrst")
        {
            atlasBuilder.AddTexture("Textures/" + c.ToString());
        }
        TextureItem[] items = atlasBuilder.Pack();

        watch.Stop();
        Debug.Log("Time to pack: " + watch.ElapsedMilliseconds);

        _batcher.AddTextureItems(items);

        renderer.material.mainTexture = atlasBuilder.atlasTexture;

        _root = new Container(new Vector2(0, 0));

        //		Container upperLeft = new Container("Textures/b", new Vector2(0, 0));
        //		upperLeft.batcher = _batcher;
        //
        //		Container lowerRight = new Container("Textures/b", new Vector2(Screen.width - 512f, Screen.height - 512f));
        //		lowerRight.batcher = _batcher;
        //
        //		_root.AddChild(upperLeft);
        //		_root.AddChild(lowerRight);

        for(int i = 0; i < 100; i++) {
            AddStuffToContainer(_root);
        }
    }