Minor TextPic updates while writing docs.
Added individual scale and offset options to image replacementsrelease
parent
8c2d10dccc
commit
703120b5b9
|
@ -62,6 +62,13 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
base.OnValidate();
|
base.OnValidate();
|
||||||
UpdateQuadImage();
|
UpdateQuadImage();
|
||||||
|
for (int i = 0; i < inspectorIconList.Length; i++)
|
||||||
|
{
|
||||||
|
if (inspectorIconList[i].scale == Vector2.zero)
|
||||||
|
{
|
||||||
|
inspectorIconList[i].scale = Vector2.one;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -75,11 +82,12 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
public string name;
|
public string name;
|
||||||
public Sprite sprite;
|
public Sprite sprite;
|
||||||
|
public Vector2 offset;
|
||||||
|
public Vector2 scale;
|
||||||
}
|
}
|
||||||
public IconName[] inspectorIconList;
|
public IconName[] inspectorIconList;
|
||||||
|
|
||||||
private Dictionary<string, Sprite> iconList = new Dictionary<string, Sprite>();
|
[Tooltip("Global scaling factor for all images")]
|
||||||
|
|
||||||
public float ImageScalingFactor = 1;
|
public float ImageScalingFactor = 1;
|
||||||
|
|
||||||
// Write the name or hex value of the hyperlink color
|
// Write the name or hex value of the hyperlink color
|
||||||
|
@ -103,10 +111,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
private string previousText = "";
|
private string previousText = "";
|
||||||
public bool isCreating_m_HrefInfos = true;
|
public bool isCreating_m_HrefInfos = true;
|
||||||
|
|
||||||
/**
|
|
||||||
* Unity Inspector cant display Dictionary vars,
|
|
||||||
* so we use this little hack to setup the iconList
|
|
||||||
*/
|
|
||||||
new void Start()
|
new void Start()
|
||||||
{
|
{
|
||||||
button = GetComponentInParent<Button>();
|
button = GetComponentInParent<Button>();
|
||||||
|
@ -126,14 +131,6 @@ namespace UnityEngine.UI.Extensions
|
||||||
highlightselectable = GetComponent<Selectable>();
|
highlightselectable = GetComponent<Selectable>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inspectorIconList != null && inspectorIconList.Length > 0)
|
|
||||||
{
|
|
||||||
foreach (IconName icon in inspectorIconList)
|
|
||||||
{
|
|
||||||
// Debug.Log(icon.sprite.name);
|
|
||||||
iconList.Add(icon.name, icon.sprite);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reset_m_HrefInfos ();
|
Reset_m_HrefInfos ();
|
||||||
base.Start();
|
base.Start();
|
||||||
}
|
}
|
||||||
|
@ -176,11 +173,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
|
|
||||||
var spriteName = match.Groups[1].Value;
|
var spriteName = match.Groups[1].Value;
|
||||||
//var size = float.Parse(match.Groups[2].Value);
|
|
||||||
var img = m_ImagesPool[m_ImagesVertexIndex.Count - 1];
|
var img = m_ImagesPool[m_ImagesVertexIndex.Count - 1];
|
||||||
|
Vector2 imgoffset = Vector2.zero;
|
||||||
if (img.sprite == null || img.sprite.name != spriteName)
|
if (img.sprite == null || img.sprite.name != spriteName)
|
||||||
{
|
{
|
||||||
// img.sprite = Resources.Load<Sprite>(spriteName);
|
|
||||||
if (inspectorIconList != null && inspectorIconList.Length > 0)
|
if (inspectorIconList != null && inspectorIconList.Length > 0)
|
||||||
{
|
{
|
||||||
foreach (IconName icon in inspectorIconList)
|
foreach (IconName icon in inspectorIconList)
|
||||||
|
@ -188,16 +184,17 @@ namespace UnityEngine.UI.Extensions
|
||||||
if (icon.name == spriteName)
|
if (icon.name == spriteName)
|
||||||
{
|
{
|
||||||
img.sprite = icon.sprite;
|
img.sprite = icon.sprite;
|
||||||
|
img.rectTransform.sizeDelta = new Vector2(fontSize * ImageScalingFactor * icon.scale.x, fontSize * ImageScalingFactor * icon.scale.y);
|
||||||
|
imgoffset = icon.offset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
img.rectTransform.sizeDelta = new Vector2(fontSize * ImageScalingFactor, fontSize * ImageScalingFactor);
|
|
||||||
img.enabled = true;
|
img.enabled = true;
|
||||||
if (positions.Count == m_ImagesPool.Count)
|
if (positions.Count == m_ImagesPool.Count)
|
||||||
{
|
{
|
||||||
img.rectTransform.anchoredPosition = positions[m_ImagesVertexIndex.Count - 1];
|
img.rectTransform.anchoredPosition = positions[m_ImagesVertexIndex.Count - 1] += imgoffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,6 +451,8 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hyperlinks Info
|
/// Hyperlinks Info
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue