示例#1
0
        public int Preload <Resource>(string pattern, LoadProgressDelegate progressCallback, string bundle) where Resource : Cv_Resource, new()
        {
            Cv_ResourceBundle resBundle;

            if (!m_ResourceBundles.TryGetValue(bundle, out resBundle))
            {
                Cv_Debug.Error("Could not find requested resource bundle.");
                return(0);
            }

            var resourceList = GetResourceList(pattern, bundle);
            int loaded       = 0;

            foreach (var r in resourceList)
            {
                GetResource <Resource>(r, bundle);
                loaded++;

                bool cancel = false;
                progressCallback(loaded * 100 / resourceList.Length, out cancel);

                if (cancel)
                {
                    break;
                }
            }

            return(loaded);
        }
示例#2
0
    /// <summary>
    /// Initializes the UWKWebView, registers default delagates, and creates textures for the page and icon
    /// to lack of constructor parameters
    /// </summary>    
    void Awake()
    {
        // ensure core is up
        UWKCore.Init();

        if (createMode)
        {
            URL = createURL;
            MaxWidth = createMaxWidth;
            MaxHeight = createMaxHeight;
            CurrentWidth = MaxWidth;
            CurrentHeight = MaxHeight;
        }

        if (MaxWidth < 64)
            MaxWidth = 64;

        if (MaxHeight < 64)
            MaxHeight = 64;

        if (CurrentWidth > MaxWidth)
            CurrentWidth = MaxWidth;
        if (CurrentHeight > MaxHeight)
           		CurrentHeight = MaxHeight;

        maxWidth = MaxWidth;
        maxHeight = MaxHeight;

        // default delegate handlers
        LoadFinished += loadFinished;
        URLChanged += urlChanged;
        TitleChanged += titleChanged;
        JSConsole += jsConsole;
        JSMessageReceived += jsMessageReceived;
        LoadProgress += loadProgress;
        ContentSizeChanged += contentSizeChanged;
        NewViewRequested += newViewRequested;

        TextureFormat format = TextureFormat.ARGB32;

        if (SystemInfo.graphicsDeviceVersion.IndexOf("Direct3D 11") != -1)
        {
            format = TextureFormat.BGRA32;
        }

        // note that on Direct3D11 shared gpu textures, mipmapping is not allowed
        WebTexture = new Texture2D( MaxWidth, MaxHeight, format, false);

        Color32[] colors = new Color32[MaxWidth * MaxHeight];

        for (int i = 0; i < MaxWidth * MaxHeight; i++)
        {
            colors[i]. r = colors[i].g = colors[i].b = colors[i]. a = 0;
        }

        WebTexture.SetPixels32(colors);
        WebTexture.Apply();

        ID = UWKCore.CreateView(this, MaxWidth, MaxHeight, "", WebTexture.GetNativeTexturePtr());
    }
示例#3
0
    /// <summary>
    /// Initializes the UWKWebView, registers default delagates, and creates textures for the page and icon
    /// to lack of constructor parameters
    /// </summary>
    void Awake()
    {
        // ensure core is up
        UWKCore.Init();

        if (createMode)
        {
            URL           = createURL;
            MaxWidth      = createMaxWidth;
            MaxHeight     = createMaxHeight;
            CurrentWidth  = MaxWidth;
            CurrentHeight = MaxHeight;
        }

        if (MaxWidth < 64)
        {
            MaxWidth = 64;
        }

        if (MaxHeight < 64)
        {
            MaxHeight = 64;
        }

        if (CurrentWidth > MaxWidth)
        {
            CurrentWidth = MaxWidth;
        }
        if (CurrentHeight > MaxHeight)
        {
            CurrentHeight = MaxHeight;
        }

        maxWidth  = MaxWidth;
        maxHeight = MaxHeight;

        // default delegate handlers
        LoadFinished       += loadFinished;
        URLChanged         += urlChanged;
        TitleChanged       += titleChanged;
        JSConsole          += jsConsole;
        JSMessageReceived  += jsMessageReceived;
        LoadProgress       += loadProgress;
        ContentSizeChanged += contentSizeChanged;
        NewViewRequested   += newViewRequested;

        TextureFormat format = TextureFormat.ARGB32;

        if (SystemInfo.graphicsDeviceVersion.IndexOf("Direct3D 11") != -1)
        {
            format = TextureFormat.BGRA32;
        }

        // note that on Direct3D11 shared gpu textures, mipmapping is not allowed
        WebTexture = new Texture2D(MaxWidth, MaxHeight, format, false);

        Color32[] colors = new Color32[MaxWidth * MaxHeight];

        for (int i = 0; i < MaxWidth * MaxHeight; i++)
        {
            colors[i].r = colors[i].g = colors[i].b = colors[i].a = 0;
        }

        WebTexture.SetPixels32(colors);
        WebTexture.Apply();

        ID = UWKCore.CreateView(this, MaxWidth, MaxHeight, "", WebTexture.GetNativeTexturePtr());
    }
 public Cv_PreloadAssetsProcess(string assetExpression, string bundle, LoadProgressDelegate loadProgressDelegate)
 {
     m_sAssetExpression     = assetExpression;
     m_sBundle              = bundle;
     m_LoadProgressDelegate = loadProgressDelegate;
 }