public void UpdateQuadImage() { m_OutputText = GetOutputText(m_Text); Debug.Log("UpdateQuadImage" + m_OutputText); m_ImagesVertexIdx.Clear(); m_ImagesPool.Clear(); foreach (Match match in s_ImageRegex.Matches(m_OutputText)) { var picIdx = match.Index + match.Length - 1; var endIdx = picIdx * 4 + 3; var spriteName = match.Groups[1].Value; var size = float.Parse(match.Groups[2].Value); Debug.Log("UpdateQuadImage.Match" + spriteName.ToString()); m_ImagesVertexIdx.Add(endIdx); if (null != spriteName) { var resources = new DefaultControls.Resources(); var go = DefaultControls.CreateImage(resources); go.layer = gameObject.layer; var rt = go.transform as RectTransform; if (rt) { rt.SetParent(rectTransform); rt.localPosition = Vector3.zero; rt.localRotation = Quaternion.identity; rt.localScale = Vector3.one; } m_ImagesPool.Add(go.GetComponent <Image>()); var img = m_ImagesPool[m_ImagesVertexIdx.Count - 1]; Debug.Log(m_ImagesPool[m_ImagesVertexIdx.Count - 1]); img.sprite = TextExImageMngr.GetInstance().GetSprite(spriteName); img.rectTransform.sizeDelta = new Vector2(size, size); } } }
// Use this for initialization void Start() { if (Instance) { Debug.LogError("[TextExImageMngr] [Error] [不能有多个TextExImageMngr!!!]"); } Instance = this; for (int i = 0; i < sprNames.Count; i++) { Debug.Log(sprNames[i]); Debug.Log(sprs[i]); m_Sprites.Add(sprNames[i], sprs[i]); } LinkImageText.funLoadSprite = (spriteName) => { Sprite spr = TextExImageMngr.GetInstance().GetSprite(spriteName); if (spr == null) { spr = Resources.Load <Sprite>(spriteName); } return(spr); }; }