コード例 #1
0
        public void CreateFontFile(string prefabPath, string fontName)
        {
            MText_Font newFont = ScriptableObject.CreateInstance <MText_Font>();
            GameObject fontSet = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;

            newFont.UpdateCharacterList(fontSet);
            string scriptableObjectSaveLocation = EditorUtility.SaveFilePanel("Save font location", "", fontName, "asset");

            scriptableObjectSaveLocation = FileUtil.GetProjectRelativePath(scriptableObjectSaveLocation);
            AssetDatabase.CreateAsset(newFont, scriptableObjectSaveLocation);
            AssetDatabase.SaveAssets();
        }
コード例 #2
0
        public void CreateFontFile(string prefabPath, string fontName, MText_FontCreator fontCreator)
        {
            MText_Font newFont = ScriptableObject.CreateInstance <MText_Font>();
            GameObject fontSet = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;

            newFont.UpdateCharacterList(fontSet);
            for (int i = 0; i < newFont.characters.Count; i++)
            {
                newFont.characters[i].glyphIndex = fontCreator.Index(newFont.characters[i].character);
            }

            if (fontCreator.KerningSupported())
            {
                newFont = GetKerning(fontCreator, newFont);
            }

            string scriptableObjectSaveLocation = EditorUtility.SaveFilePanel("Save font location", "", fontName, "asset");

            scriptableObjectSaveLocation = FileUtil.GetProjectRelativePath(scriptableObjectSaveLocation);
            AssetDatabase.CreateAsset(newFont, scriptableObjectSaveLocation);
            AssetDatabase.SaveAssets();
        }