/// <summary>Sets the isolated state of this batch.</summary> public void IsIsolated(DisplayableProperty property){ if(Isolated && Setup){ // No change. return; } Setup=true; Isolated=true; FontAtlas=null; GraphicsAtlas=null; IsolatedProperty=property; }
/// <summary>Sets the isolated state of this batch.</summary> public void NotIsolated(TextureAtlas graphics,TextureAtlas font,float alias){ if(!Isolated && Setup){ return; } Setup=true; Isolated=false; IsolatedProperty=null; Mesh.SetGlobalMaterial(); SetFontAtlas(font,alias); SetGraphicsAtlas(graphics); }
/// <summary>Permanently destroys this UI batch.</summary> public void Destroy(){ if(Renderer==null){ return; } if(IsolatedProperty!=null){ IsolatedProperty.Isolated=false; IsolatedProperty.OnBatchDestroy(); IsolatedProperty=null; } if(Mesh!=null){ Mesh.Destroy(); Mesh=null; } Renderer=null; }
/// <summary>Sets up the current batch based on the isolation settings requested by a property.</summary> /// <param name="property">The displayable property which wants the batch.</param> /// <param name="fontTexture">The font texture to use with this batch.</param> public void SetupBatch(DisplayableProperty property,TextureAtlas graphics,TextureAtlas font){ if(UI.MainCameraPool!=null && InWorldUI==null){ // This is the main UI and it also has a camera pool. // Are we now attempting to create a batch on top of an inline camera? // Let the camera pool check: if(UI.MainCameraPool.CheckCameraRequired()){ // Clear the current batch - it can't be shared any further. CurrentBatch=null; } } if(property.Isolated){ if(property.GotBatchAlready){ // The property already got a batch on this layout - it doesn't need another. return; } // Isolated properties always get a new batch every time. CurrentBatch=UIBatchPool.Get(this); if(CurrentBatch==null){ CurrentBatch=new UIBatch(this); } property.GotBatchAlready=true; // And push it to the active stack: AddBatch(CurrentBatch); // Make sure it knows it's isolated: CurrentBatch.IsIsolated(property); }else{ if(CurrentBatch!=null && !CurrentBatch.Isolated){ // Re-use existing batch? if(font!=null){ if(CurrentBatch.FontAtlas==null){ // Didn't have one assigned before. Assign now: CurrentBatch.SetFontAtlas(font,FontAliasing); }else if(font!=CurrentBatch.FontAtlas){ // Font atlas changed. Can't share. CurrentBatch=null; } } if(graphics!=null){ if(CurrentBatch.GraphicsAtlas==null){ // Didn't have one assigned before. Assign now: CurrentBatch.SetGraphicsAtlas(graphics); }else if(graphics!=CurrentBatch.GraphicsAtlas){ // Atlas changed. Can't share. CurrentBatch=null; } } if(CurrentBatch!=null){ // Yep - reuse it. return; } } // Pull a batch from the pool and set it to currentbatch. May need to generate a new one. CurrentBatch=UIBatchPool.Get(this); if(CurrentBatch==null){ CurrentBatch=new UIBatch(this); } // And push it to the active stack: AddBatch(CurrentBatch); // Make sure it knows it's not isolated: CurrentBatch.NotIsolated(graphics,font,FontAliasing); } // Finally, prepare it for layout: CurrentBatch.PrepareForLayout(); }