Exemplo n.º 1
0
    /// <summary>加载通道分离图片</summary>
    /// <param name="target"></param>
    /// <param name="url"></param>
    public static void LoadChannelSeparationImage(UITexture target, string url)
    {
        Texture texture_rgb;
        Texture texture_alpha;

        ResourceManager.Instance.LoadTexture(url + "_rgb.png", delegate(AssetBundles.NormalRes res)
        {
            AssetBundles.TextureRes tex = res as AssetBundles.TextureRes;

            texture_rgb = tex.m_texture as Texture;

            ResourceManager.Instance.LoadTexture(url + "_alpha.png", delegate(AssetBundles.NormalRes res2)
            {
                AssetBundles.TextureRes tex2 = res2 as AssetBundles.TextureRes;

                texture_alpha = tex2.m_texture as Texture;

                Shader sder = Shader.Find("Custom/Unlit - Transparent Colored Grayed (SoftClip)");

                Material mat = new Material(sder);
                mat.SetTexture("_MainTex", texture_rgb);
                mat.SetTexture("_AlphaTex", texture_alpha);

                target.mainTexture = null;
                target.material    = mat;
            },
                                                 OnLoader_Error);
        },
                                             OnLoader_Error);
    }
Exemplo n.º 2
0
    public static void LoaderImage(UITexture target, string url, bool autoNativeSize = false)
    {
        ResourceManager.Instance.LoadTexture(url + ".png", delegate(AssetBundles.NormalRes res)
        {
            AssetBundles.TextureRes tex = res as AssetBundles.TextureRes;

            target.mainTexture = tex.m_texture;
        },
                                             delegate(string errorString)
        {
            Debug.LogError(errorString);
        });
    }