示例#1
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());
    }
示例#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());
    }