// return true if case of success, else false public bool UpdateRuntimeSprites(int currentScreenWidth, int currentScreenHeight, out float scale) { float newScale = SVGRuntimeGenerator.ScaleFactorCalc((float)this.m_ReferenceWidth, (float)this.m_ReferenceHeight, currentScreenWidth, currentScreenHeight, this.m_ScaleType, this.m_Match, this.m_OffsetScale); if (Math.Abs(this.m_RuntimeGenerationScale - newScale) > Single.Epsilon) { scale = newScale; return(this.UpdateRuntimeSprites(newScale)); } else { scale = this.m_RuntimeGenerationScale; return(true); } }
// used by SVGAtlasEditor, upon the "Update" button click (recalcScale = true); this function is used even // in the build post-processor, in order to restore sprites (recalcScale = false) public void UpdateEditorSprites(bool recalcScale) { float newScale; if (recalcScale) { Vector2 gameViewRes = SVGUtils.GetGameView(); float currentWidth = (this.m_DeviceTestWidth <= 0) ? gameViewRes.x : (float)this.m_DeviceTestWidth; float currentHeight = (this.m_DeviceTestHeight <= 0) ? gameViewRes.y : (float)this.m_DeviceTestHeight; newScale = SVGRuntimeGenerator.ScaleFactorCalc((float)this.m_ReferenceWidth, (float)this.m_ReferenceHeight, currentWidth, currentHeight, this.m_ScaleType, this.m_Match, this.m_OffsetScale); } else { newScale = this.m_EditorGenerationScale; } this.UpdateEditorSprites(newScale); }
// Calculate the scale factor that would be used to generate sprites if the screen would have the specified dimensions public float ScaleFactorCalc(int currentScreenWidth, int currentScreenHeight) { return(SVGRuntimeGenerator.ScaleFactorCalc((float)this.m_ReferenceWidth, (float)this.m_ReferenceHeight, currentScreenWidth, currentScreenHeight, this.m_ScaleType, this.m_Match, this.m_OffsetScale)); }