DemoList.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. namespace ZenFulcrum.EmbeddedBrowser {
  4. [RequireComponent(typeof(Browser))]
  5. public class DemoList : MonoBehaviour {
  6. protected List<string> demoSites = new List<string> {
  7. "localGame://demo/MouseShow.html",//simple, cheap circle follows mouse, fade
  8. "http://js1k.com/2013-spring/demo/1487",//kalidescope effect around mouse
  9. // "http://js1k.com/2013-spring/demo/1471",//black balls follow mouse
  10. "http://js1k.com/2014-dragons/demo/1868", //webgl blobs
  11. "http://glimr.rubyforge.org/cake/missile_fleet.html",//spaceships shoot each other
  12. "http://js1k.com/2015-hypetrain/demo/2231", //galaxy
  13. "http://js1k.com/2015-hypetrain/demo/2313",//particles, music
  14. "http://js1k.com/2015-hypetrain/demo/2331", //wave simulator in a dot grid
  15. "http://js1k.com/2015-hypetrain/demo/2315",//drag starfield
  16. "http://js1k.com/2015-hypetrain/demo/2161", //animated 3d fractal
  17. "http://js1k.com/2013-spring/demo/1533", //raindrop noise/music
  18. "http://js1k.com/2014-dragons/demo/1969",//many cube lines
  19. "http://www.snappymaria.com/misc/TouchEventTest.html",//circle around mouse cursor
  20. // "http://js1k.com/2013-spring/demo/1456",//plasma
  21. // "http://js1k.com/2013-spring/demo/1511",//circles around the mouse cursor
  22. };
  23. public Browser demoBrowser;
  24. private Browser panelBrowser;
  25. private int currentIndex = 0;
  26. protected void Start() {
  27. panelBrowser = GetComponent<Browser>();
  28. panelBrowser.RegisterFunction("go", args => {
  29. DemoNav(args[0].Check());
  30. });
  31. demoBrowser.onLoad += info => {
  32. panelBrowser.CallFunction("setDisplayedUrl", demoBrowser.Url);
  33. };
  34. demoBrowser.Url = demoSites[0];
  35. }
  36. private void DemoNav(int dir) {
  37. if (dir > 0) {
  38. currentIndex = (currentIndex + 1) % demoSites.Count;
  39. } else {
  40. currentIndex = (currentIndex - 1 + demoSites.Count) % demoSites.Count;
  41. }
  42. demoBrowser.Url = demoSites[currentIndex];
  43. }
  44. }
  45. }