Esempio n. 1
0
    IEnumerator LoadDropIcon(uint iconId, Sprite3DEx sprite3D, uint loadId)
    {
        sprite3D.RenderEnable = false;

        SGameEngine.AssetResource ar = new SGameEngine.AssetResource();
        IconInfo info     = GoodsHelper.GetIconInfo(iconId);
        var      iconPath = info.MainTexturePath;

        yield return(xc.MainGame.GetGlobalMono().StartCoroutine(SGameEngine.ResourceLoader.Instance.load_asset(iconPath, typeof(Texture), ar)));

        // 检查资源
        var tex = ar.asset_ as Texture;

        if (tex == null)
        {
            GameDebug.LogError("LoadDropIcon is failed");
            yield break;
        }

        // 检查loadId是否变化/sprite3D组件
        if (loadId != mCurLoadIconID || sprite3D == null)
        {
            ar.destroy();
            yield break;
        }

        mDropIconRes = ar;

        sprite3D.SetTexture(tex, iconPath);
        sprite3D.UVOffset     = info.IconRect;
        sprite3D.RenderEnable = true;
    }