/// <summary>
        ///
        /// </summary>
        /// <param name="srcGlyphID"></param>
        /// <param name="dstGlyphID"></param>
        bool AddNewGlyph(int srcIndex, int dstGlyphID)
        {
            // Make sure Destination Glyph ID doesn't already contain a Glyph
            if (m_fontAsset.characterDictionary.ContainsKey(dstGlyphID))
            {
                return(false);
            }

            // Add new element to glyph list.
            m_glyphInfoList_prop.arraySize += 1;

            // Get a reference to the source glyph.
            SerializedProperty sourceGlyph = m_glyphInfoList_prop.GetArrayElementAtIndex(srcIndex);

            int dstIndex = m_glyphInfoList_prop.arraySize - 1;

            // Get a reference to the target / destination glyph.
            SerializedProperty targetGlyph = m_glyphInfoList_prop.GetArrayElementAtIndex(dstIndex);

            CopySerializedProperty(sourceGlyph, ref targetGlyph);

            // Update the ID of the glyph
            targetGlyph.FindPropertyRelative("id").intValue = dstGlyphID;

            serializedObject.ApplyModifiedProperties();

            m_fontAsset.SortGlyphs();

            m_fontAsset.ReadFontDefinition();

            return(true);
        }
Exemplo n.º 2
0
        private bool AddNewGlyph(int srcIndex, int dstGlyphID)
        {
            if (m_fontAsset.characterDictionary.ContainsKey(dstGlyphID))
            {
                return(false);
            }
            m_glyphInfoList_prop.arraySize++;
            SerializedProperty arrayElementAtIndex = m_glyphInfoList_prop.GetArrayElementAtIndex(srcIndex);
            int index = m_glyphInfoList_prop.arraySize - 1;
            SerializedProperty target = m_glyphInfoList_prop.GetArrayElementAtIndex(index);

            CopySerializedProperty(arrayElementAtIndex, ref target);
            target.FindPropertyRelative("id").intValue = dstGlyphID;
            base.serializedObject.ApplyModifiedProperties();
            m_fontAsset.SortGlyphs();
            m_fontAsset.ReadFontDefinition();
            return(true);
        }