private void RecalculateMetrics() { int atlasWidth, atlasHeight; EditorInternalUtility.GetImageSize(this.tilesetTexture, out atlasWidth, out atlasHeight); this.tileWidth = Mathf.Clamp(this.tileWidth, 1, atlasWidth); this.tileHeight = Mathf.Clamp(this.tileHeight, 1, atlasHeight); this.tilesetMetrics.Calculate(this.tilesetTexture, this.tileWidth, this.tileHeight, this.borderSize, this.delta); }
/// <summary> /// Calculate metrics for specified tileset. /// </summary> /// <remarks> /// <para>Measurements are relative to original atlas size.</para> /// </remarks> /// <param name="atlas">Atlas texture for tileset.</param> /// <param name="tileWidth">Width of tile in pixels.</param> /// <param name="tileHeight">Height of tile in pixels.</param> /// <param name="borderSize">Border size in pixels.</param> /// <param name="delta">UV delta offset (fraction of pixel).</param> /// <returns> /// A value of <c>true</c> when valid atlas was specified; otherwise a value of <c>false</c>. /// </returns> public bool Calculate(Texture2D atlas, int tileWidth, int tileHeight, int borderSize, float delta) { int atlasWidth, atlasHeight; if (!EditorInternalUtility.GetImageSize(atlas, out atlasWidth, out atlasHeight)) { this.Clear(); return(false); } return(this.Calculate(atlasWidth, atlasHeight, tileWidth, tileHeight, borderSize, delta)); }