예제 #1
0
        static void ClearFontAssetData(MenuCommand command)
        {
            FontAsset fontAsset = command.context as FontAsset;

            if (fontAsset == null)
            {
                return;
            }

            if (Selection.activeObject != fontAsset)
            {
                Selection.activeObject = fontAsset;
            }

            fontAsset.ClearFontAssetData(true);
            TextResourceManager.RebuildFontAssetCache();

            TextEventManager.ON_FONT_PROPERTY_CHANGED(true, fontAsset);
        }
        void DoPreRenderUpdates()
        {
            // Handle Font Asset Definition Refresh
            for (int i = 0; i < m_FontAssetDefinitionRefreshQueue.Count; i++)
            {
                FontAsset fontAsset = m_FontAssetDefinitionRefreshQueue[i];

                if (fontAsset != null)
                {
                    fontAsset.ReadFontAssetDefinition();
                    TextEventManager.ON_FONT_PROPERTY_CHANGED(true, fontAsset);
                }
            }

            if (m_FontAssetDefinitionRefreshQueue.Count > 0)
            {
                m_FontAssetDefinitionRefreshQueue.Clear();
                m_FontAssetDefinitionRefreshQueueLookup.Clear();
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            SerializedProperty prop_BaseGlyphID          = property.FindPropertyRelative("m_BaseMarkGlyphID");
            SerializedProperty prop_BaseGlyphAnchorPoint = property.FindPropertyRelative("m_BaseMarkGlyphAnchorPoint");

            SerializedProperty prop_MarkGlyphID          = property.FindPropertyRelative("m_CombiningMarkGlyphID");
            SerializedProperty prop_MarkAdjustmentRecord = property.FindPropertyRelative("m_CombiningMarkPositionAdjustment");

            position.yMin += 2;

            float width   = position.width / 2;
            float padding = 5.0f;

            Rect rect;

            isEditingEnabled = GUI.enabled;
            isSelectable     = label.text == "Selectable" ? true : false;

            if (isSelectable)
            {
                GUILayoutUtility.GetRect(position.width, 75);
            }
            else
            {
                GUILayoutUtility.GetRect(position.width, 55);
            }

            GUIStyle style = new GUIStyle(EditorStyles.label)
            {
                richText = true
            };

            // Base Glyph
            GUI.enabled = isEditingEnabled;
            if (isSelectable)
            {
                float labelWidth = GUI.skin.label.CalcSize(new GUIContent("ID: " + prop_BaseGlyphID.intValue)).x;

                if (!isEditingEnabled)
                {
                    EditorGUI.LabelField(new Rect(position.x + (64 - labelWidth) / 2, position.y + 60, 64f, 18f), new GUIContent("ID: <color=#FFFF80>" + prop_BaseGlyphID.intValue + "</color>"), style);
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUIUtility.labelWidth = 25f;
                    EditorGUI.DelayedIntField(new Rect(position.x + (64 - labelWidth) / 2, position.y + 60, 64, 18), prop_BaseGlyphID, new GUIContent("ID:"));
                    if (EditorGUI.EndChangeCheck())
                    {
                        FontAsset fontAsset = property.serializedObject.targetObject as FontAsset;
                        if (fontAsset != null)
                        {
                            property.serializedObject.ApplyModifiedProperties();
                            fontAsset.ReadFontAssetDefinition();
                            TextEventManager.ON_FONT_PROPERTY_CHANGED(true, fontAsset);
                        }
                    }
                }

                GUI.enabled = isEditingEnabled;
                EditorGUIUtility.labelWidth = 30f;

                rect = new Rect(position.x + 70, position.y + 10, (width - 70) - padding, 18);
                EditorGUI.PropertyField(rect, prop_BaseGlyphAnchorPoint.FindPropertyRelative("m_XCoordinate"), new GUIContent("X:"));

                rect.y += 20;
                EditorGUI.PropertyField(rect, prop_BaseGlyphAnchorPoint.FindPropertyRelative("m_YCoordinate"), new GUIContent("Y:"));

                DrawGlyph((uint)prop_BaseGlyphID.intValue, new Rect(position.x, position.y, position.width, position.height), property);
            }

            // Mark Glyph
            GUI.enabled = isEditingEnabled;
            if (isSelectable)
            {
                float labelWidth = GUI.skin.label.CalcSize(new GUIContent("ID: " + prop_MarkGlyphID.intValue)).x;

                if (!isEditingEnabled)
                {
                    EditorGUI.LabelField(new Rect(position.width / 2 + 20 + (64 - labelWidth) / 2, position.y + 60, 64f, 18f), new GUIContent("ID: <color=#FFFF80>" + prop_MarkGlyphID.intValue + "</color>"), style);
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUIUtility.labelWidth = 25f;
                    EditorGUI.DelayedIntField(new Rect(position.width / 2 + 20 + (64 - labelWidth) / 2, position.y + 60, 64, 18), prop_MarkGlyphID, new GUIContent("ID:"));
                    if (EditorGUI.EndChangeCheck())
                    {
                        FontAsset fontAsset = property.serializedObject.targetObject as FontAsset;
                        if (fontAsset != null)
                        {
                            property.serializedObject.ApplyModifiedProperties();
                            fontAsset.ReadFontAssetDefinition();
                            TextEventManager.ON_FONT_PROPERTY_CHANGED(true, fontAsset);
                        }
                    }
                }

                GUI.enabled = isEditingEnabled;
                EditorGUIUtility.labelWidth = 30f;

                rect = new Rect(position.width / 2 + 20 + 70, position.y + 10, (width - 70) - padding, 18);
                EditorGUI.PropertyField(rect, prop_MarkAdjustmentRecord.FindPropertyRelative("m_XPositionAdjustment"), new GUIContent("X:"));

                rect.y += 20;
                EditorGUI.PropertyField(rect, prop_MarkAdjustmentRecord.FindPropertyRelative("m_YPositionAdjustment"), new GUIContent("Y:"));

                DrawGlyph((uint)prop_MarkGlyphID.intValue, new Rect(position.width / 2 + 20, position.y, position.width, position.height), property);
            }
        }