Exemplo n.º 1
0
        void Go()
        {
            WeAreProcessing = true;
            zeit.Start();
            //   if (FindTextureByPosition(player.position.x, transform.position.z))
            //       return;

            // Mesher
            vertices         = new List <Vector3>();
            triangles        = new List <int>();
            meshFilterMesh   = mesher.GetComponent <MeshFilter>().mesh;
            meshColliderMesh = mesher.GetComponent <MeshCollider>().sharedMesh;
            size             = 10; // lenght of the mesh in Z direction
            loop             = 0;

            // Sprite
            //      pixels = oldTexture.GetPixels();

            Texture2D myTexture = DirectTexturesHolder.FindTexture(MapMagicObjectRef, "Road", player.position.x, player.position.z);


            //   Debug.Log(myTexture.format);
            //   Debug.Log(myTexture.width);
            //   Debug.Log(myTexture.height);

            pixels = myTexture.GetPixels();

            newTexture = new Texture2D(myTexture.width, myTexture.height, TextureFormat.RGBA32, false);


            if ((TryGetComponent(out SpriteRenderer spriteRenderer)))
            {
            }
Exemplo n.º 2
0
        public bool FindTextureByPosition(float x, float z)
        {
            bool stop = true;

            // did we already run? and did we not move in xz.

            if (oldPosition.x == x && oldPosition.z == z)
            {
                //we should have already assigned the texture. Just return
                Debug.Log("early return ");
                return(stop);
            }


            // Let's find the Texture Holder and then return the texture as a reference into oldTexture

            TerrainTile tileFound = MapMagicObjectRef.tiles.FindByWorldPosition(x, z);

            // We just did that to see if the tile exists really.

            if (null == tileFound)
            {
                Debug.Log("no data yet ");
                return(stop);
            }
            else
            {
                //    DirectTexturesHolder holder = tileFound.GetComponentInChildren<DirectTexturesHolder>();

                Debug.Log("Finding for " + x + " " + z);

                oldTexture = DirectTexturesHolder.FindTexture(MapMagicObjectRef, "Road", x, z);

                Debug.Log(oldTexture.isReadable);
                stop = false;
            }

            System.TimeSpan ts = zeit.Elapsed;
            zeit.Stop();
            Debug.Log(ts.TotalMilliseconds);

            zeit.Reset();

            oldPosition = new Vector3(x, z);

            return(stop);
        }