Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Coherent UI - HTML5-based User Interface middleware

Discussion in 'Assets and Asset Store' started by stoyannk, Oct 30, 2012.

  1. sirival

    sirival

    Joined:
    Sep 14, 2011
    Posts:
    146
    To be honest I am not sure that we needed to install it in each system after the commit. I believe that we installed it last night on another machine and Coherent UI was giving an error saying that you need to install it.

    Regarding the build server, we basically did what you suggested, we are setting the player pref when the editor is started and that works. It'd be cool to also be able to give the folder our own name instead of it having to be UIResources - we can probably change the source code for that too, but I'd like to make minimal changes to it so that we can easily update in the future.
     
  2. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    I see that we have a check in the player preferences whether the "Install" step has been run, we'll think of a better way of enforcing running the step after importing the package.

    You can use whatever name you like for your UI resources folder - as long as you have set it the "CoherentUIResources" player preference to contain the path to this folder. The "UIResources" part of "coui://UIResources/game_hud.html" is not actually used and the game_hud.html is loaded from
    the folder stored in "CoherentUIResources".
     
  3. sirival

    sirival

    Joined:
    Sep 14, 2011
    Posts:
    146
    This might actually be a bug, because initially we had named our folder: "CoherentUiResources". After we built the game, the "CoherentUiResources" folder was correctly copied inside the game_data folder, however the CoherentUIViews were not displaying our pages. After renaming that folder to UIResources the game worked so we assumed that the folder must always be named like that.

    Unless you mean that we need to set the player pref in the release version of the game as well - at the moment we only do this in the Editor.
     
  4. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Actually my previous post wasn't entirely correct
    The UIResources part is ignored in the Editor, but it is used in the standalone game.
    The url coui://UIResources/game_hud.html will be loaded from
    game_Data/UIResources/game_hud.html (on Windows) when the game is exported.

    So to use a different named folder you'll have to select it with the menu entry and change the coui:// URLs so that they use the name of the folder as host.
     
  5. sirival

    sirival

    Joined:
    Sep 14, 2011
    Posts:
    146
    Oh I see. Ok we'll give that a shot at some point - thanks for your help.
     
  6. sirival

    sirival

    Joined:
    Sep 14, 2011
    Posts:
    146
    Hi there,

    We are getting an exception on one of our builds on a CoherentUIView that loads one of our html pages:
    Code (csharp):
    1.  
    2. DllNotFoundException: C:/Users/avaca/Desktop/deploy/Game/game_Data/Plugins/CoherentUI_Native.dll
    3.   at (wrapper managed-to-native) Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_CoherentUI_Native (Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate,Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate,Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate,Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate,Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate,Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate,Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate,Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate,Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate,Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate,Coherent.UI.CoherentUI_NativePINVOKE/SWIGExceptionHelper/ExceptionDelegate)
    4.  
    5.   at Coherent.UI.CoherentUI_NativePINVOKE+SWIGExceptionHelper..cctor () [0x00000] in <filename unknown>:0
    6. Rethrow as TypeInitializationException: An exception was thrown by the type initializer for SWIGExceptionHelper
    7.   at Coherent.UI.CoherentUI_NativePINVOKE..cctor () [0x00000] in <filename unknown>:0
    8. Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Coherent.UI.CoherentUI_NativePINVOKE
    9.   at Coherent.UI.MouseEventData..ctor () [0x00000] in <filename unknown>:0
    10.  
    11.   at CoherentUISystem..ctor () [0x00000] in <filename unknown>:0
    12. UnityEngine.GameObject:AddComponent(String)
    13. CoherentUISystem:Create()
    14. CoherentUIView:Awake()
    15.  
    As you can see it complains about not being able to find CoherentUI_Native.dll at the specified location. However that dll exists in that location...

    The same build works on other systems with the same operating system. I have also seen this error in the Unity Editor from time to time, usually when I restart the editor and try to load a URL in a short time.
     
  7. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Probably some Windows DLL CoherentUI_Native.dll depends on is missing on this system.
    My guess is that the missing DLL is the DirectX redistributable - you can download it from http://www.microsoft.com/en-us/download/details.aspx?id=8109

    You can use some tool like Dependency Walker on CoherentUI_Native.dll to check which DLL is missing.
     
    Last edited: Jun 7, 2013
  8. sirival

    sirival

    Joined:
    Sep 14, 2011
    Posts:
    146
    Hmm... This is probably it.. Ok we'll check it out thanks :)
     
  9. stoyannk

    stoyannk

    Joined:
    Oct 30, 2012
    Posts:
    35
    Coherent UI is coming to mobile devices!
    Coherent UI Mobile is currently in beta. It will be available in all our current Coherent Labs products for Unity at no additional cost. There also will be a standalone version for developer who work only on mobile applications.
    Read more here!
     
  10. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I'm not a mobile developer, but this is really good news. I've been using CoherentUI for my entire UI and it's fantastic.
     
  11. stoyannk

    stoyannk

    Joined:
    Oct 30, 2012
    Posts:
    35
  12. Gatu

    Gatu

    Joined:
    May 20, 2013
    Posts:
    9
    Hello,

    First of all congrats on your mobile version...it looks really cool.
    Looking forward to check it.

    For the time being i am using the desktop version and recently i tried to play an html5 game using CoherentUi. While the game starts normally in any browser i cant get it to start through the plugin. Its like my clicks don't "reach" the game. (the game can be found here : http://www.alexh.org/battleships/ )Do you have any idea why is this happening? I understand that this might be an issue of the game, but i need some help to figure this out (maybe the way the game tries to "catch" the user input? Something that the plugin does in a specific way?)
    Let me clarify that every click up to that point works fine.

    Thanks
    George
     
  13. nikxio

    nikxio

    Joined:
    Oct 30, 2012
    Posts:
    69
    Hi Gatu,

    I checked that game in a very simple scene (just one camera) and it didn't have any problems.

    Make sure you either set the ReceivesInput property of the CoherentUIView to true (you can do this only programatically, e.g. in the Start method of a component in the same object would be the easiest) or use the click-to-focus feature (available in the Inspector) if it suits you - it forwards input to the view upon clicking it and stops forwarding when you click somewhere else.

    If you're using the CoherentUIView component on a 3D object, make sure it has a Mesh collider so the texture coordinates of the raycast are reported, as they are needed to compute the position inside the view.

    Please let me know if this solved your issue or you're still having trouble. :)
     
  14. Gatu

    Gatu

    Joined:
    May 20, 2013
    Posts:
    9
    Hi nikxio

    Everything works fine with any other page i load. Its this one specifically that causes me trouble.
    Also tried to create a new project (just the main camera ,add CoherentUI View , set click to focus) and load the page
    No luck there either.
    I am using CoherentUI 1_2_2 trial version on windows 7 with Unity 4.1.3f3(just saying)

    One thing i noticed is a warning : "Requesting resource read for file:///C:/Users/.../New Unity Project 1/cookies.dat with internal id 0 reported FAIL
     
  15. nikxio

    nikxio

    Joined:
    Oct 30, 2012
    Posts:
    69
    Hi again,

    I've further investigated the issue and it seems to be a problem with the page. It doesn't seem to always work in a browser, too. For example using Chrome with Windows works only if the inspector is shown on one machine (but works fine on another). It also doesn't work in Chrome on Mac, but works on Safari.

    The problematic part of the code I found is in battleships_min.js, line 1639 (de-minified)

    Code (csharp):
    1. alex.screens.ScreenBase.prototype.enableTouch = function() {
    2.     this.useTouch = Modernizr.touch;
    3.     ...
    and the
    Code (csharp):
    1. tests['touch'] = function()
    function on line 262 in modernizr.js which is used to set the Modernizr.touch property.

    If the touch property is true then the event handlers attached are for touches and not clicks. If it's false then clicks work.

    To work around the problem you can remove the touch logic if you don't need it or always attach click handlers, regardless of the value of tests['touch'].
     
  16. Gatu

    Gatu

    Joined:
    May 20, 2013
    Posts:
    9
    Thank you very much nikxio.
    The game is not mine, i was just doing some tests to see if i can integrate html5 games using CoherentUI and ran into this.
    Good to know nothing wrong with CoherentUI.

    Thanks again!
     
  17. frutian

    frutian

    Joined:
    Jun 26, 2013
    Posts:
    1
    Hello! Is webRTC supported and how i can enable web camera from Unity?
     
  18. Zapgun

    Zapgun

    Joined:
    Jun 3, 2011
    Posts:
    50
    Hi there,

    I'm interested in buying, but I'd like a bit of information about some of the features you may (or may not) offer. I'm building a game that allows my players to add/mod some content (forms basically) that can be displayed in game, and I'd like to know how feasible that is. My basic questions are:

    - Just how 'HTML 5' enabled is Coherent UI, for example, if I wanted to allow my players to access and modify a JavaScript-based web database (I know this isn't officially a part of HTML 5), would that be feasible? (if not I have an alternative system in place, but this would be nice).
    - How much player-based UI customization can I offer my players? For example, do coherent UI items need to be packaged up at build time before they can be used, or is it possible to include 'raw' HTML forms in a player-accessible folder that they can then modify?

    Thanks in advance for your reply :)

    - Zapgun
     
  19. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    webRTC is supported as a JavaScript API, but we haven't provided API for enabling and using the user camera or microphone yet. We are going to add these features in one of the next releases of Coherent UI for Unity3D.
     
  20. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    What do you mean by "JavaScript web database" - the Web SQL Database, IndexedDB
    or something else?
    You can use both - Web SQL Database and IndexedDB in Coherent UI. Keep in mind that Web SQL Database didn't
    make it into the standard, so there is a chance that we stop supporting it.

    About the customization - you have complete freedom to allow what your users can customize. Coherent UI loads 'raw' HTML, CSS and JavaScript (and other resources). By default the loading is from a plain folder on the disk. You can leave it that way or you can load some files (that should not be modified by users) from encrypted archives and others - from 'raw' files, easily modifiable by your users.
     
  21. Zapgun

    Zapgun

    Joined:
    Jun 3, 2011
    Posts:
    50
    Thanks for getting back to me so quickly.

    Web SQL Database was what I was thinking, since I feel its what people would be most comfortable with, (so I hope you keep it). IndexDB would be my second (but still acceptable) choice.

    The customization sounds ideal! I'll grab your trial later today for a in-depth look, but I think its exactly what I'm looking for.

    Thanks again,

    Zapgun
     
  22. Zapgun

    Zapgun

    Joined:
    Jun 3, 2011
    Posts:
    50
    Hi again,

    I was curious if you had any updates on the Linux port?

    Cheers and thanks,

    Zapgun
     
  23. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Hi,

    Unfortunately there is a bug in Unity3D support for Linux - plugins with native rendering don't work at all on Linux.

    Here is our bug report for this: https://fogbugz.unity3d.com/default.asp?542562_a9k5sett5qt5gcql

    As soon as they fix this, we'll make sure Coherent UI works too.
     
  24. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hi there,

    We are trying to integrate html5 games in out actual game and we are using cUI to test it out. The problem is that we get very low frame rates for the html minigames. The only playable (smooth) solution was to make the resolution of Coherent View to be 256x256. Of course thats a too low res and we would like to be able to have better resolution obviously, but at least in 256x256 is smooth.

    Do you have any tips as of how to increase the frame rate of the coherent viewer as to be more smooth? Any ideas where to look at for things that might hinder it?

    Thanks
     
  25. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99

    Hi,
    The performance quite depends on the html game itself, on the OS and on the hardware.
    For most html5 games we have excellent performance - here is a video of Bunny mark
    running in Coherent UI.


    Can you give us details about the html game, the OS and the hardware that you are running.
    I suppose that you prefer to not disclose details about your game so contact us directly at support@coherent-labs.com.

    Also you can use the Timeline and the Profiles tabs of Coherent UI Debugger in order to profile the game itself and see what is causing the low fps.
     
  26. Zapgun

    Zapgun

    Joined:
    Jun 3, 2011
    Posts:
    50
    Thanks.. hopefully resolved soon!

    - Zapgun
     
  27. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Hi,
    Well, yes, that video looks blazing fast compared to what we get. The rig currently testing this on, is Win7 64x, i7, 4 GB Ram, 660GTX. I guess those would suffice :). The actual html game that we load doesn't really matter. For the time being we tried a lot of different games found on the web for testing purposes and all run about the same. It is worth noting, that the scene in which the coherent viewer is in, is quite heavy loaded, something similar in load as the angry bots demo for an estimation.

    The bunny mark indeed runs fast on us too, but for example those 2 games on a 1024x1024 viewer, are extremely slow:

    http://yvoschaap.com/chainrxnadvanced/
    http://pasjans-online.pl/

    Now, I understand that the solitaire looks a bit heavy, but the other looks simple enough. We will also get a look at the UI debugger tomorrow.
    Thanks
     
  28. sirival

    sirival

    Joined:
    Sep 14, 2011
    Posts:
    146
    Hi there. This is a screenshot of the profiler. 97.87% of the time is spent inside the (program). What does that mean?

    $profiler.jpg
     
  29. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    I tried both games in our mini-game integration sample with angry bots and both keep up the maximum fps (the first one is implemented to run at 30fps, I modified it a bit and it runs smooth at 60fps too), the second one keeps 60 fps vsynced. This is on a i7, Nvidia 470GTX system.

    I suppose that you are using the latest drivers from NVidia.
    Are you running Unity3D vsynced? If not - there is a chance that the system is overwhelmed and doesn't give enough resources for Coherent UI?
    Try making the view with the mini-game "On Demand".

    I suggest you contact us at support@coherent-labs.com. It will be much faster for us to reproduce the issue if send us your scene.
     
  30. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    (program) is Chromium / WebKit internal code. From this I suggest that your view is not scripting bound actually.

    My suggestion for profiling is to use the Timeline first, see what part of the HTML rendering engine is the bottleneck - scripting, layout, painting, rendering is the bottleneck and then profile it.
     
  31. sirival

    sirival

    Joined:
    Sep 14, 2011
    Posts:
    146
    Hi and thanks for the response. I am running the debugger but the Timeline does not show anything. Is there a button I should press for it to do something? I hope I'm not missing something obvious like a total noob!
     
  32. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Yes, there is a "Record" button at the bottom of the Debugger.
    The Timeline has quite a few features and it not very intuitive to use. Here is a nice intro how to it:

    https://developers.google.com/chrome-developer-tools/docs/timeline
     
  33. sirival

    sirival

    Joined:
    Sep 14, 2011
    Posts:
    146
    So we run the game using vsync and indeed the HTML games are very smooth now. We also tried On Demand views without vsync and that also works well. However in the latter case, Unity hangs when we create / destroy an On Demand CoherentUIView a couple times. We add the view as a component to a gameobject dynamically and set OnDemand to true immediately after AddComponent. Is this a problem or is it irrelevant?

    We'd like to use On Demand views instead of vsync if possible and this crash is the only issue I see at the moment.
     
  34. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Is it possible to forward UI mouse cursor to the game? I'd love to be able to style the in-game cursor using CSS through the UI. This would make it much easier to style cursors for hover events, etc.. is is possible for this to be implemented or doable now?
     
  35. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    After further experiments with setup similar to yours we found a bug in the On Demand views implementation for Unity3D that causes a hang of Unity.
    I believe that this is the same bug you are experiencing. We have fixed the bug in the just released version 1.4.2.0. It is not available on the Asset Store yet, but you can take the trial from http://coherent-labs.com/UIDownload/?select=unity3d .
     
  36. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Hi,

    There is no way for Coherent UI to render the cursor instead of Unity3D, but Unity3D has an API for changing the cursor

    Here is a sample component that finds the RenderTexture of a Coherent UI view attached to a surface and changes the cursor.


    Code (csharp):
    1.  
    2. public class Cursor : MonoBehaviour {
    3.    
    4.     RenderTexture m_ViewRenderTexture;
    5.    
    6.     void Start ()
    7.     {
    8.         var viewComponent = GetComponent<CoherentUIView>();
    9.         viewComponent.Listener.ViewCreated += (view) => {
    10.             var renderTextures = RenderTexture.FindObjectsOfType(typeof(RenderTexture));
    11.             var name = "CoherentRenderingRTT" + view.GetId();
    12.             foreach (var renderTexture in renderTextures)
    13.             {
    14.                 if (renderTexture.name == name) {
    15.                     m_ViewRenderTexture = (RenderTexture)renderTexture;
    16.                     break;
    17.                 }
    18.             }
    19.         };
    20.     }
    21.    
    22.     void Update ()
    23.     {
    24.         if (Input.GetKeyDown(KeyCode.F7)  m_ViewRenderTexture != null  m_ViewRenderTexture.IsCreated())
    25.         {
    26.             var previousActiveTexture = RenderTexture.active;
    27.            
    28.             RenderTexture.active = m_ViewRenderTexture;
    29.  
    30.             var cursorTexture = new Texture2D(32, 32, TextureFormat.ARGB32, false);
    31.             cursorTexture.ReadPixels(new Rect(256, 0, 256 + 32, 0 + 32), 0, 0, false);
    32.             cursorTexture.Apply();
    33.            
    34.             RenderTexture.active = previousActiveTexture;
    35.            
    36.             Cursor.SetCursor(cursorTexture, new Vector2(0, 0), CursorMode.Auto);
    37.         }
    38.     }
    39. }
    40.  
    In order to minimize the Texture2D.ReadPixels calls the best way will be to use a texture atlas with all cursors:
    1 .create view with all your cursors
    2. Create a Texture2D with each of your cursors using ReadPixels. You may destroy the view now.
    3. Change the cursor using Cursor.SetCursor with the specific Texture2D


    If you want to be notified by Coherent UI which cursor should be displayed, you can listen for the CursorChanged event of
    the view listener instance.
     
    Last edited: Jul 9, 2013
  37. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I see, seams best to just have a script be notified when the cursor changes then change it with Unity API. Can you provide an example of how to listen to this event using C#? Does it work when CSS changes the cursor?
     
  38. Molt

    Molt

    Joined:
    Sep 6, 2011
    Posts:
    103
    Is there any way to disable the internet connection part of Coherent UI completely in order to force it to only be able to use coui:// resources?

    I'm working on a system which'll have a lot of user-provided linked data, written in Markdown and rendered via Coherent, and while I want them to be able to link from one of the internal page to another I don't want them to be able to link outside of the system to external web pages.
     
  39. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Here is a component that logs what kind of cursor the should be displayed. Changing the cursor in CSS triggers the event too.

    Code (csharp):
    1.  
    2. public class CursorMonitor : MonoBehaviour {
    3.  
    4.     void Start ()
    5.     {
    6.         var viewComponent = GetComponent<CoherentUIView>();
    7.  
    8.        
    9.         viewComponent.Listener.CursorChanged += (cursor) => {
    10.             Debug.Log (string.Format ("Cursor changes to {0}", cursor));
    11.         };
    12.     }
    13. }
    14.  
     
  40. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    It is possible, you have to tell the view that you want to intercept all URL requests and then you can either forbid or redirect to a special error page all requests to the outside world.

    Code (csharp):
    1.  
    2. class URLLoadMonitor: MonoBehaviour
    3. {
    4.     public void Start()
    5.     {
    6.         var viewComponent = GetComponent<CoherentUIView>();
    7.         viewComponent.OnViewCreated += (view) => { view.InterceptURLRequests(true); };
    8.         viewComponent.Listener.URLRequest += OnURLRequestHandler;
    9.     }
    10.    
    11.     void OnURLRequestHandler (string url, URLResponse response)
    12.     {
    13.         if (url.StartsWith("http"))
    14.         {
    15.             response.DenyRequest(); // or response.RedirectRequest("coui://UIResources/BadRequest.html");
    16.         }
    17.                 else
    18.                 {
    19.                         response.AllowRequest();
    20.                 }
    21.     }
    22. }
    23.  
     
  41. Molt

    Molt

    Joined:
    Sep 6, 2011
    Posts:
    103
    Excellent, thought it would be possible but couldn't see how to do it. I think I'm going to have to dig a bit into that Listener, it looks like it's capable of a lot more than I suspected.
     
  42. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Awesome, thank you very much!
     
  43. Chris-HG

    Chris-HG

    Joined:
    Aug 10, 2012
    Posts:
    63
    Hello.

    Can you show us a jQuery UI implementation on iOS? I would be interested in seeing basic UI navigation.
     
  44. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    I don't think completely understand the question.
    Can you be a little more specific, please?
     
  45. Chris-HG

    Chris-HG

    Joined:
    Aug 10, 2012
    Posts:
    63
  46. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Ok, I have cursor handling implemented and the cursor it returns is CT_TypeHand or CT_TypePointer for example. Is it possible for it to supply a texture, which is the cursor image file? Would be really cool if this is possible. If not then I can just do IF statements and change it around as needed.

    Also I know you can bind a call with BindCall, but can you Unbind a call? I'm using PlayMaker to dynamically create bindings and I want to remove the bindings after it has trigger so it's only bound during the state that bound it. I'd like to do the same for RegisterForEvent too, basically once the event that is registered fires I want to remove the registration for it.

    I'm able to do this with ReadyForBindings for example by doing the below.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3.  
    4. namespace HutongGames.PlayMaker.Actions {
    5.     [ActionCategory("Coherent UI")]
    6.     public class CuiViewReadyForBindings : FsmStateAction {
    7.         [ObjectType(typeof(CoherentUIView)), Tooltip("The View component. Not needed if View GameObject is used.")]
    8.         public FsmObject viewObject;
    9.         [Tooltip("GameObject reference to View. Not needed if View Object is used.")]
    10.         public FsmOwnerDefault viewGameObject;
    11.         public FsmEvent readyEvent;
    12.         [UIHint(UIHint.Variable)]
    13.         public FsmBool storeReady;
    14.  
    15.         private CoherentUIView view;
    16.         private bool bound;
    17.  
    18.         public override void Reset() {
    19.             viewObject = new FsmObject { UseVariable = true };
    20.             viewGameObject = null;
    21.             readyEvent = null;
    22.             storeReady = false;
    23.         }
    24.  
    25.         public override void OnEnter() {
    26.             DoAction();
    27.         }
    28.  
    29.         void DoAction() {
    30.             if ( bound == false ) {
    31.                 bound = true;
    32.  
    33.                 if ( viewObject.Value == null ) {
    34.                     var go = Fsm.GetOwnerDefaultTarget( viewGameObject );
    35.    
    36.                     if ( go == null ) {
    37.                         return;
    38.                     }
    39.    
    40.                     view = go.GetComponent<CoherentUIView>();
    41.                 } else {
    42.                     view = viewObject.Value as CoherentUIView;
    43.                 }
    44.    
    45.                 if ( view == null ) {
    46.                     return;
    47.                 }
    48.    
    49.                 view.Listener.ReadyForBindings += HandleReadyForBindings;
    50.             }
    51.         }
    52.  
    53.         void HandleReadyForBindings( int frameId, string path, bool isMainFrame ) {
    54.             if ( isMainFrame ) {
    55.                 bound = false;
    56.  
    57.                 view.Listener.ReadyForBindings -= HandleReadyForBindings;
    58.  
    59.                 storeReady.Value = true;
    60.  
    61.                 if ( readyEvent != null ) {
    62.                     Fsm.Event( readyEvent );
    63.                 }
    64.  
    65.                 Finish();
    66.             }
    67.         }
    68.     }
    69. }
    70.  
    You can see in the HandleReadyForBindings for handling the event it removes the binding.
     
    Last edited: Jul 14, 2013
  47. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Here is a screenshot of JQuery Mobile running fullscreen in Unity3D via Coherent UI. Since it is plain JavaScript and CSS - it is working out of the box.
    All you have to do is:
    - add a CoherentUIView to the MainCamera
    - set the InputState to "Take All", so that all input is consumed by CoherentUI
    - load a page that is using jQuery Mobile.

    We'll think of a better sample to include in one of the next releases.

    $jQueryMobile.png
     
  48. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Currently, the CursorChanged event cannot supply a texture for the cursor.
    You can use a separate view to create an atlas of cursors rendered by Coherent UI and then change the cursor to one of the textures in the atlas.

    There is no explicit API for unbinding calls and un-registering event handlers at the moment. We are going to add this prety soon,
    because is it relatively popular request.
    At the moment all the registered handlers are removed if the view is reloaded or the URL is changed.

    I am not quite accustomed to PlayMaker, but if you are binding only methods you can use:

    1. export the object with its method to JavaScript via Coherent.UI.Binding.BoundObject.BindMethods(handler)
    Code (csharp):
    1.  
    2. public void OnBindingsReady(int frameId, string url, bool isMain)
    3. {
    4.   engine.trigger('setHandler", Coherent.UI.Binding.BoundObject.BindMethods(handler) );
    5. }
    6.  
    And in JavaScript
    Code (csharp):
    1.  
    2. engine.on('setHandler', function (handler) {
    3.     myHandler = handler;
    4.  
    5.     myHandler.SomeMethod(42).then(function (result) { } );
    6.  
    7.     engine.on('event', myHandler .EventHandler, myHandler );
    8. });
    9.  
    10.  
    2. Instead of engine.call you can use myHandler .Method()
    3. attach the methods of the instance in JavaScript using engine.on('event', myHandler .EventHandler, myHandler )

    When the instance is no longer necessary you should remove all references to it in JavaScript, as well as methods registered to events using engine.off('event', handler.Method, handler) - This will notify Coherent UI to remove its references to the handler object in .Net so that it can be garbage-collected / destroyed.

    Let me know whether this works for you.
     
  49. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    No urgency so I'll just wait for the unbinding and unregister feature. As is everything is working ok, but in my case where everything is defined by a state it needs to unbind/unregister after the state has been exited.
     
  50. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    Hello,
    I know that Unity pro is required for this plugin but I was wondering if unity ios pro is also required if I was to develop for ios?