예제 #1
0
    static void main()
    {
        Object target = Selection.activeObject;

        if (target == null || target.GetType() != typeof(Texture2D))
        {
            return;
        }

        Texture2D sourceTex = target as Texture2D;
        //整体路径
        string filePathWithName = AssetDatabase.GetAssetPath(sourceTex);
        //带后缀的文件名
        //string fileNameWithExtension = Path.GetFileName(filePathWithName);
        //string filePath = filePathWithName.Replace(fileNameWithExtension, "");


        string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePathWithName);

        InlineSpriteAsset inlineSpriteAsset = AssetDatabase.LoadAssetAtPath(TargetPath + fileNameWithoutExtension + ".asset", typeof(InlineSpriteAsset)) as InlineSpriteAsset;
        bool isNewAsset = inlineSpriteAsset == null ? true : false;

        // if (isNewAsset)
        {
            inlineSpriteAsset = ScriptableObject.CreateInstance <InlineSpriteAsset>();
            inlineSpriteAsset.TextureSource   = sourceTex;
            inlineSpriteAsset.listSpriteInfor = GetSpritesInfor(sourceTex);

            AssetDatabase.CreateAsset(inlineSpriteAsset, TargetPath + fileNameWithoutExtension + ".asset");
        }

        CheckSprite(sourceTex);

        Debug.Log("_______________________________File:" + fileNameWithoutExtension + "Gerenated sucess");
    }
예제 #2
0
    private bool CheckSpriteAsset()
    {
        if (inlineSpriteAsset != null && inlineSpriteAsset.TextureSource != null)
        {
            return(true);
        }

        //TODO
        inlineSpriteAsset = Resources.Load <InlineSpriteAsset>(defaultSpriteAssetResPath);
        if (inlineSpriteAsset == null)
        {
            Debug.LogError(defaultSpriteAssetResPath + " Load Failed");
            return(false);
        }
        return(true);
    }
예제 #3
0
    protected override void Awake()
    {
        if (inlineSpriteAsset != null && inlineSpriteAsset.TextureSource != null)
        {
            return;
        }

        InlineTextManager.Instance.RebulidSpriteData();

        inlineSpriteAsset = InlineTextManager.Instance.InlineSpriteAsset;

        UpdateMaterial();

        transform.localPosition = new Vector3(1000, 1000, 1000);

        base.Awake();
    }
 public void OnEnable()
 {
     inlineSpriteAsset = (InlineSpriteAsset)target;
 }