Esempio n. 1
0
        public static DialogHandler Create(Browser parent, DialogCallback dialogCallback, MenuCallback contextCallback)
        {
            if (dialogPage == null)
            {
                dialogPage = Resources.Load <TextAsset>("Browser/Dialogs").text;
            }
            GameObject    gameObject = new GameObject("Browser Dialog for " + parent.name);
            DialogHandler handler    = gameObject.AddComponent <DialogHandler>();

            handler.parentBrowser  = parent;
            handler.dialogCallback = dialogCallback;
            Browser browser = (handler.dialogBrowser = handler.GetComponent <Browser>());

            browser.UIHandler          = parent.UIHandler;
            browser.EnableRendering    = false;
            browser.EnableInput        = false;
            browser.allowContextMenuOn = BrowserNative.ContextMenuOrigin.Editable;
            browser.Resize(parent.Texture);
            browser.LoadHTML(dialogPage, "about:dialog");
            browser.UIHandler = parent.UIHandler;
            browser.RegisterFunction("reportDialogResult", delegate(JSONNode args)
            {
                dialogCallback(args[0], args[1], args[3]);
                handler.Hide();
            });
            browser.RegisterFunction("reportContextMenuResult", delegate(JSONNode args)
            {
                contextCallback(args[0]);
                handler.Hide();
            });
            return(handler);
        }
Esempio n. 2
0
        public void Awake()
        {
            var keyboardPage = Resources.Load <TextAsset>("Browser/Keyboard").text;

            keyboardBrowser = GetComponent <Browser>();

            keyboardBrowser.onBrowserFocus += OnKeyboardFocus;
            keyboardBrowser.LoadHTML(keyboardPage);
            keyboardBrowser.RegisterFunction("textTyped", TextTyped);
            keyboardBrowser.RegisterFunction("commandEntered", CommandEntered);

            if (initialBrowser)
            {
                ActiveBrowser = initialBrowser;
            }

            if (automaticFocus)
            {
                foreach (var browser in FindObjectsOfType <Browser>())
                {
                    ObserveBrowser(browser);
                }
                Browser.onAnyBrowserCreated += ObserveBrowser;
            }

            if (hideWhenUnneeded)
            {
                SetVisible(false);
            }
        }
Esempio n. 3
0
        public void Start()
        {
            HUDBrowser = hud.GetComponent <Browser>();
            HUDBrowser.RegisterFunction("unpause", args => Unpause());
            HUDBrowser.RegisterFunction("quit", args => Application.Quit());

            Unpause();

                #if UNITY_STANDALONE_LINUX
            StartCoroutine(Rehide());
                #endif

            //Update coin count on hud when user gets one
            PlayerInventory.Instance.coinCollected += count => HUDBrowser.CallFunction("setCoinCount", count);
        }
Esempio n. 4
0
        public void Awake()
        {
            var keyboardPage = Resources.Load <TextAsset>("Browser/Keyboard").text;

            keyboardBrowser = GetComponent <Browser>();

            keyboardBrowser.onBrowserFocus += OnBrowserFocus;
            keyboardBrowser.LoadHTML(keyboardPage);
            keyboardBrowser.RegisterFunction("textTyped", TextTyped);
            keyboardBrowser.RegisterFunction("commandEntered", CommandEntered);

            if (initialBrowser)
            {
                ActiveBrowser = initialBrowser;
            }

            if (automaticFocus)
            {
                StartCoroutine(FindAndListenForBrowsers());
            }
        }
Esempio n. 5
0
        protected void Start()
        {
            panelBrowser = GetComponent <Browser>();
            panelBrowser.RegisterFunction("go", args => {
                DemoNav(args[0].Check());
            });

            demoBrowser.onLoad += info => {
                panelBrowser.CallFunction("setDisplayedUrl", demoBrowser.Url);
            };

            demoBrowser.Url = demoSites[0];
        }
Esempio n. 6
0
        public void Start()
        {
            browser = GetComponent <Browser>();

            //Load some HTML. Normally you'd want to use BrowserAssets + localGame://,
            //but let's just put everything here for simplicity/visibility right now.
            browser.LoadHTML(@"

<p >&nbsp;</p >
<p >&nbsp;</p >
<table style=""margin - left: auto; margin - right: auto; "" >
	        <tbody>
	        <tr>
	        <td><strong> Trigger </strong></td>
	        <td><strong> Display </strong></td>
	        <td><strong> Valve </strong></td>
	        </tr>
	        <tr>
	        <td><img onclick = ""spawnObject(1)"" src = ""http://192.168.0.105:3000/v1/objects/resources/c9/c949de70-7e44-42b7-b34e-b84efd1afbf1/bundle.png"" /></td>
	        <td><img onclick = ""spawnObject(2)"" src = ""http://192.168.0.105:3000/v1/objects/resources/c9/c949de70-7e44-42b7-b34e-b84efd1afbf2/bundle.png"" /></td>
	        <td><img onclick = ""spawnObject(4)"" src = ""http://192.168.0.105:3000/v1/objects/resources/c9/c949de70-7e44-42b7-b34e-b84efd1afbf5/bundle.png"" /></td>
	        </tr>
	        <tr>
	        <td><strong> Zone </strong></td>
	        <td><strong> Animated </strong></td>
	        <td><strong> Liquid </strong></td>
	        </tr>
	        <tr>
	        <td><img onclick = ""spawnObject(5)"" src = ""http://192.168.0.105:3000/v1/objects/resources/c9/c949de70-7e44-42b7-b34e-b84efd1afbf6/bundle.png"" /></td>
	        <td><img onclick = ""spawnObject(7)"" src = ""http://192.168.0.105:3000/v1/objects/resources/a7/a759f163-146d-40b1-a1b6-11dd01063faa/bundle.png"" /></td>
	        <td><img onclick = ""spawnObject(13)"" src = ""http://192.168.0.105:3000/v1/objects/resources/d0/d0277246-8289-4439-9732-c438f16648cc/bundle.png"" /></td>
	        </tr>
	        </tbody>
	        </table>
                                                                      ");

            //Set up a function. Notice how the <button > above calls this function when it's clicked.
            browser.RegisterFunction("spawnObject", args => {
                //Args is an array of arguments passed to the function.
                //args[n] is a JSONNode. When you use it, it will implicitly cast to the type at hand.
                int xPos = args[0];
                //int yPos = args[1];

                //Note that if, say, args[0] was a string instead of an integer we'd get default(int) above.
                //See JSONNode.cs for more information.

                Debug.Log("The <color=green >green</color > button was clicked at " + xPos + ", ");
            });
        }
        public void Start()
        {
            browser = GetComponent <Browser>();

            //Load some HTML. Normally you'd want to use BrowserAssets + localGame://,
            //but let's just put everything here for simplicity/visibility right now.
            browser.LoadHTML(@"
<button style='background: green; color: white' onclick='greenButtonClicked(event.x, event.y)'>Green Button</button>


<br><br>


Username: <input type='text' id='username' value='CouchPotato47'>


<br><br>


<div id='box' style='width: 200px; height: 200px;border: 1px solid black'>
	Click ""Change Color""
</div>

<script>
function changeColor(r, g, b, text) {
	var el = document.getElementById('box');
	el.style.background = 'rgba(' + (r * 255) + ', ' + (g * 255) + ', ' + (b * 255) + ', 1)';
	el.textContent = text;
}
</script>
");

            //Set up a function. Notice how the <button> above calls this function when it's clicked.
            browser.RegisterFunction("greenButtonClicked", args => {
                //Args is an array of arguments passed to the function.
                //args[n] is a JSONNode. When you use it, it will implicitly cast to the type at hand.
                int xPos = args[0];
                int yPos = args[1];

                //Note that if, say, args[0] was a string instead of an integer we'd get default(int) above.
                //See JSONNode.cs for more information.

                Debug.Log("The <color=green>green</color> button was clicked at " + xPos + ", " + yPos);
            });
        }