protected override void ApplyTexture(Texture2D texture, TextureOrientation orientation) { var renderer = GetComponent <Renderer>(); if (renderer != null && renderer.sharedMaterial != null) { renderer.material.mainTexture = texture; // Optional: Support arbitrary texture orientation by flipping the texture if necessary var scale = renderer.material.mainTextureScale; scale.x = orientation.IsXFlipped() ? -1 : 1; scale.y = orientation.IsYFlipped() ? -1 : 1; renderer.material.mainTextureScale = scale; } }
protected override void ApplyTexture(Texture2D texture, TextureOrientation orientation) { Vector2 pos = new Vector2(0, 0); Vector2 size = new Vector2(texture.width, texture.height); if (orientation.IsXFlipped()) { pos.x = size.x; size.x *= -1; } if (orientation.IsYFlipped()) { pos.y = size.y; size.y *= -1; } GetComponent <Image>().sprite = Sprite.Create(texture, new Rect(pos, size), Vector2.zero); }
void ApplyTexture(Texture2D texture, TextureOrientation orientation) { Profiler.BeginSample("ApplyTexture"); if (texture == null) { return; } total_count++; Debug.LogFormat("Added image {0}", total_count); var b = Object.Instantiate <Renderer>(prefab); b.transform.position = new Vector3( (Random.value - .5f) * spread * aspectRatio, (Random.value - .5f) * spread, distance ); distance += step; b.material.mainTexture = texture; var scale = b.material.mainTextureScale; scale.x = orientation.IsXFlipped() ? -1 : 1; scale.y = orientation.IsYFlipped() ? -1 : 1; b.material.mainTextureScale = scale; rendererQueue.Enqueue(b); while (rendererQueue.Count > MAX_ITEMS) { var r = rendererQueue.Dequeue(); r.enabled = false; } if (batch_count > 0) { batch_count--; if (batch_count == 0) { batch_time = Time.realtimeSinceStartup - start_time; Debug.LogFormat("Batch load time: {0}", batch_time); batch_count = -1; } } Profiler.EndSample(); }