예제 #1
0
 private void OnEnable()
 {
     m_ConsoleContent = string.Empty;
     m_TextureSource  = null;
     m_TPTextSheet    = null;
     m_FontAsset      = null;
     InitGUIStyle();
 }
예제 #2
0
    private static void AddDefaultMaterial(BMFontAsset spriteAsset)
    {
        Shader   shader   = Shader.Find("UI/Default");
        Material material = new Material(shader);

        material.SetTexture("_MainTex", spriteAsset.spriteSheet);
        spriteAsset.material = material;
        material.hideFlags   = HideFlags.HideInHierarchy;
        AssetDatabase.AddObjectToAsset(material, spriteAsset);
    }
예제 #3
0
    public void OnEnable()
    {
        this.m_SpriteAtlas         = base.serializedObject.FindProperty("spriteSheet");
        this.m_Material            = base.serializedObject.FindProperty("material");
        this.m_spriteInfoList_prop = base.serializedObject.FindProperty("spriteInfoList");


        m_BMFontAsset = target as BMFontAsset;

        if (m_BMFontAsset == null)
        {
            return;
        }

        SetupGroup();
    }
예제 #4
0
    private void SaveSpriteAsset(string filePath)
    {
        filePath = filePath.Substring(0, filePath.Length - 6);
        string dataPath = Application.dataPath;

        if (filePath.IndexOf(dataPath, StringComparison.InvariantCultureIgnoreCase) == -1)
        {
            Debug.LogError("You're saving the font asset in a directory outside of this project folder. This is not supported. Please select a directory under \"" + dataPath + "\"");
            return;
        }
        string path                     = filePath.Substring(dataPath.Length - 6);
        string directoryName            = Path.GetDirectoryName(path);
        string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
        string str = directoryName + "/" + fileNameWithoutExtension;

        if (!File.Exists(filePath + ".asset"))
        {
            this.m_FontAsset = ScriptableObject.CreateInstance <BMFontAsset>();
            AssetDatabase.CreateAsset(this.m_FontAsset, str + ".asset");
        }
        else
        {
            this.m_FontAsset = AssetDatabase.LoadAssetAtPath <BMFontAsset>(str + ".asset");
            if (this.m_FontAsset == null)
            {
                this.m_FontAsset = ScriptableObject.CreateInstance <BMFontAsset>();
                AssetDatabase.CreateAsset(this.m_FontAsset, str + ".asset");
            }
        }

        this.m_FontAsset.hashCode       = this.m_FontAsset.name.GetHashCode();
        this.m_FontAsset.spriteSheet    = this.m_TextureSource;
        this.m_FontAsset.spriteInfoList = this.m_FontSpriteInfoList;

        AddDefaultMaterial(this.m_FontAsset);

        EditorUtility.SetDirty(this.m_FontAsset);
        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();
        if (Application.isPlaying)
        {
            UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty();
        }
    }