Esempio n. 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());
    }
Esempio n. 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());
    }
Esempio n. 3
0
    void Awake()
    {
        // ensure core is up
        if (!UWKCore.Init())
        {
            return;
        }

        if (createMode)
        {
            URL           = createURL;
            MaxWidth      = createMaxWidth;
            MaxHeight     = createMaxHeight;
            InitialWidth  = createInitialWidth;
            InitialHeight = createInitialHeight;
        }

        if (InitialWidth <= 0)
        {
            InitialWidth = MaxWidth;
        }

        if (InitialHeight <= 0)
        {
            InitialHeight = MaxHeight;
        }

        InitialWidth  = Mathf.Clamp(InitialWidth, 64, 4096);
        InitialHeight = Mathf.Clamp(InitialHeight, 64, 4096);
        MaxWidth      = Mathf.Clamp(MaxWidth, 64, 4096);
        MaxHeight     = Mathf.Clamp(MaxHeight, 64, 4096);

        if (InitialWidth > MaxWidth)
        {
            MaxWidth = InitialWidth;
        }

        if (InitialHeight > MaxHeight)
        {
            MaxHeight = InitialHeight;
        }

        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();

        width  = InitialWidth;
        height = InitialHeight;

        ID = UWKCore.CreateView(this, InitialWidth, InitialHeight, MaxWidth, MaxHeight, URL, WebTexture.GetNativeTexturePtr());

        // default delegate handlers
        LoadFinished     += loadFinished;
        URLChanged       += urlChanged;
        TitleChanged     += titleChanged;
        LoadStateChanged += loadStateChanged;
        PopupRequested   += popupRequested;

        WebQuery += webQuery;
    }