示例#1
0
    /// <summary>
    /// 获取一个材质
    /// </summary>
    /// <param name="owner">资源绑定对象</param>
    /// <param name="respath">资源路径</param>
    /// <param name="callback">资源回调</param>
    /// <param name="loadtype">资源加载类型</param>
    /// <param name="loadmethod">资源加载方式</param>
    /// <returns></returns>
    public void getMaterial(UnityEngine.Object owner, string respath, Action <Material> callback = null, ResourceLoadType loadtype = ResourceLoadType.NormalLoad, ResourceLoadMethod loadmethod = ResourceLoadMethod.Sync)
    {
        ResourceModuleManager.Singleton.requstResource(respath,
                                                       (abi) =>
        {
            var assetname = Path.GetFileName(respath);
            var material  = abi.getAsset <Material>(owner, assetname);
#if UNITY_EDITOR
            ResourceUtility.FindMaterialShaderBack(material);
#endif
            callback?.Invoke(material);
        },
                                                       loadtype,
                                                       loadmethod);
    }
示例#2
0
    /// <summary>
    /// 获取一个共享的材质
    /// </summary>
    /// <param name="owner">资源绑定对象</param>
    /// <param name="resname">资源名</param>
    /// <param name="assetname">Asset名</param>
    /// <param name="callback">资源回调</param>
    /// <param name="loadtype">资源加载类型</param>
    /// <param name="loadmethod">资源加载方式</param>
    /// <returns></returns>
    public void getShareMaterial(UnityEngine.Object owner, string resname, string assetname = null, Action <Material> callback = null, ResourceLoadType loadtype = ResourceLoadType.NormalLoad, ResourceLoadMethod loadmethod = ResourceLoadMethod.Sync)
    {
        if (string.IsNullOrEmpty(assetname))
        {
            assetname = resname;
        }
        ResourceModuleManager.Singleton.requstResource(resname,
                                                       (abi) =>
        {
            var material = abi.getAsset <Material>(owner, assetname);
#if UNITY_EDITOR
            ResourceUtility.FindMaterialShaderBack(material);
#endif
            callback?.Invoke(material);
        },
                                                       loadtype,
                                                       loadmethod);
    }