Example #1
0
        public GameObject GetPoolItem(MText_Font font, char c)
        {
            string key = font.name + " " + c;

            if (poolDictionary.ContainsKey(key))
            {
                if (poolDictionary[key].Count > 0)
                {
                    GameObject poolItem = poolDictionary[key].Dequeue();
                    return(poolItem);
                }
                else
                {
                    GameObject newPoolItem = new GameObject();
                    Mesh       meshPrefab  = font.RetrievePrefab(c);
                    if (meshPrefab)
                    {
                        newPoolItem.AddComponent <MeshFilter>();
                        newPoolItem.GetComponent <MeshFilter>().sharedMesh = meshPrefab;
                        newPoolItem.SetActive(false);
                        newPoolItem.transform.SetParent(transform);
                        newPoolItem.AddComponent <MText_PoolItem>().key = key;
                        newPoolItem.name = c.ToString();
                    }
                    else
                    {
                        newPoolItem.name = "Space";
                    }

                    return(newPoolItem);
                }
            }
            else
            {
                Queue <GameObject> queue = new Queue <GameObject>();
                poolDictionary.Add(key, queue);

                GameObject newPoolItem = new GameObject();
                Mesh       meshPrefab  = font.RetrievePrefab(c);
                if (meshPrefab)
                {
                    newPoolItem.AddComponent <MeshFilter>();
                    newPoolItem.GetComponent <MeshFilter>().sharedMesh = meshPrefab;
                    newPoolItem.SetActive(false);
                    newPoolItem.transform.SetParent(transform);
                    newPoolItem.AddComponent <MText_PoolItem>().key = key;
                }
                else
                {
                    newPoolItem = new GameObject();
                }
                return(newPoolItem);
            }
        }
Example #2
0
        void OnEnable()
        {
            myTarget = (MText_Font)target;
            soTarget = new SerializedObject(target);

            rotationFix = soTarget.FindProperty("rotationFix");
            positionFix = soTarget.FindProperty("positionFix");
            scaleFix    = soTarget.FindProperty("scaleFix");

            fontSet         = soTarget.FindProperty("fontSet");
            overwriteOldSet = soTarget.FindProperty("overwriteOldSet");
            monoSpaceFont   = soTarget.FindProperty("monoSpaceFont");
            useUpperCaseLettersIfLowerCaseIsMissing = soTarget.FindProperty("useUpperCaseLettersIfLowerCaseIsMissing");
            emptySpaceSpacing = soTarget.FindProperty("emptySpaceSpacing");
            characterSpacing  = soTarget.FindProperty("characterSpacing");

            characters = soTarget.FindProperty("characters");
        }