public void Icon(ICComRect position, string texture, IconAligment horizontalAlign = IconAligment.resize, IconAligment verticalAlign = IconAligment.resize, bool tile = false) { var text = ICEditorFunc.GetIcon(texture); Icon(position, text, horizontalAlign, verticalAlign, tile); }
public void Icon(ICComRect position, Texture2D texture, IconAligment horizontalAlign = IconAligment.resize, IconAligment verticalAlign = IconAligment.resize, bool tile = false) { #if UNITY_EDITOR if (texture == null) { return; } position.Init(this); var rect = position.GetRect(margin); //aligning texture if the rect width or height is more than icon size if (rect.width > texture.width) { switch (horizontalAlign) { case IconAligment.min: rect.width = texture.width; break; case IconAligment.center: rect.x += rect.width / 2; rect.x -= texture.width / 2; rect.width = texture.width; break; case IconAligment.max: rect.x += rect.width; rect.x -= texture.width; rect.width = texture.width; break; } } if (rect.height > texture.height) { switch (verticalAlign) { case IconAligment.min: rect.height = texture.height; break; case IconAligment.center: rect.y += rect.height / 2; rect.y -= texture.height / 2; rect.height = texture.height; break; case IconAligment.max: rect.y += rect.height; rect.y -= texture.height; rect.height = texture.height; break; } } if (!tile) { GUI.DrawTexture(ToDisplay(rect), texture, ScaleMode.ScaleAndCrop); } else { //Debug.Log(zoom); Rect localRect = ToDisplay(rect); for (float x = 0; x < rect.width; x += texture.width * zoom) { for (float y = 0; y < rect.height + texture.height; y += texture.height * zoom) { GUI.DrawTexture(new Rect(x + localRect.x, y + localRect.y, texture.width * zoom + 1, texture.height * zoom + 1), texture, ScaleMode.StretchToFill); } } } #endif }