public void AdjustTextureSize(int size) { if (imposterTexture != null && imposterTexture.size == size) return; if (imposterTexture != null) { ImposterManager.instance.giveBackRenderTexture(imposterTexture); if (castShadow) ImposterManager.instance.giveBackRenderTexture(shadowTexture); } imposterTexture = ImposterManager.instance.getRenderTexture(this, size); quad.material.mainTexture = imposterTexture.texture; quad.material.SetFloat("_ZOffset", zOffset); if (castShadow) { shadow.gameObject.SetActive(true); updateShadow(size); } else { shadow.gameObject.SetActive(false); } }
public ImposterTexture getRenderTexture(ImposterProxy newOwner, int size) { //Reuse Texture? for(int i=0; i<freeImposterTextures.Count; i++) { ImposterTexture texture = freeImposterTextures[i]; if (texture.size == size) { freeImposterTextures.Remove(texture); texture.owner = newOwner; return texture; } } //Create new Texture RenderTexture renderTexture = new RenderTexture(size, size, 16); renderTexture.antiAliasing = antialiasing; ImposterTexture imposterTexture = new ImposterTexture(); imposterTexture.owner = newOwner; imposterTexture.size = size; imposterTexture.createdTime = imposterTexture.lastUsedTime = Time.frameCount; imposterTexture.texture = renderTexture; imposterTextures.Add(imposterTexture); textureMemory += imposterTexture.getMemoryAmount(); return imposterTexture; }
public void Init(List<Renderer> renderers, bool useShadow) { if (imposterTexture != null) ImposterManager.instance.giveBackRenderTexture(imposterTexture); if (shadowTexture != null) ImposterManager.instance.giveBackRenderTexture(shadowTexture); this.castShadow = useShadow; this.renderers = renderers; renderingCamera = ImposterManager.instance.imposterRenderingCamera; imposterTexture = shadowTexture = null; if (!useShadow) shadow.gameObject.SetActive(false); extractBounds(); adjustSize(); }
public void InvalidateTexture() { if (IsTextureInvalid()) { return; } ImposterManager.instance.giveBackRenderTexture(imposterTexture); imposterTexture = null; if (castShadow) { ImposterManager.instance.giveBackRenderTexture(shadowTexture); shadowTexture = null; } }
void Awake() { imposterTexture = shadowTexture = null; }
public void giveBackRenderTexture(ImposterTexture imposterTexture) { if (imposterTexture.texture == null) { Debug.LogError("Texture given back is empty!"); return; } freeImposterTextures.Add(imposterTexture); }