Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Coherent UI - HTML5-based User Interface middleware

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

  1. orca6

    orca6

    Joined:
    Jun 13, 2013
    Posts:
    9
    Yes, I know this. But I cannot call Coherent UI from OnGUI. Because my pointing device cannot call OnGUI, but only update() can read the XY coordinates of the pointing device. Then I have to do "viewComponent.View.MouseEvent(mouseEvent);" in update().
    At that time, "Event.current" is NULL.

    Am I missing anything?

    Thank you!
     
  2. orca6

    orca6

    Joined:
    Jun 13, 2013
    Posts:
    9
    Sorry but I was confused. I can get "Event.current" with no problem.
    And finally, I can pass the mouse related event to Coherent UI successfully.

    Thank you very much!
     
  3. gridside

    gridside

    Joined:
    Jul 26, 2013
    Posts:
    97
    Hi Coherent Team,

    First i want to thank you for this great product. It's solid and powerful yet easy to use. I'm currently using evaluation version and stuck on some weird situation. Using for HUD and sometimes my HUD is losing handle after click somewhere on screen. After click somewhere on screen i can't click or hover any object on Coherent UI. There's no error message on my console. I also tried to build project and still same result. What can be a problem?

    Best.
     
  4. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    Hello Getting an error and I can't figure out what the problem is. but what's even more weird is that what it complains about works perfectly.. :S

    the error:
    Code (csharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Coherent.UI.Binding.ViewExtensions.TriggerEvent[String] (Coherent.UI.View view, System.String name, System.String argument1) (at /Volumes/MacBuild/PandoStatic/Coherent/UI/DotNET/Binding/Binding.cs:91)
    3. CoherentGuiCalls.GuiCountDownSet (System.String newTime) (at Assets/scripts/CoherentGuiCalls.js:107)
    4. CoherentGuiCalls.Update () (at Assets/scripts/CoherentGuiCalls.js:38)

    and here is the entire CoherentGuiCalls.js file:
    Code (csharp):
    1.  
    2. #pragma strict
    3. import Coherent.UI.Binding;
    4.  
    5. public  var playerRef           : GameObject;       //eference to the player
    6.  
    7. private var globalVars          : GlobalVars;       // Reference to global Vars
    8. private var localVars           : LocalVars;        // Reference to local Vars
    9. private var m_View              : CoherentUIView;
    10. private var anim                : Animator;         // Reference to the animator component.
    11. private var hash                : HashIDsPlayer;    // Reference to the HashIDs.
    12.  
    13. private var currentTimeString   : String = '';
    14. private var currentAlleSeeValue : int;
    15. private var currentHealthValue  : int;
    16. private var currentGlowValue    : int;
    17. private var currentGameOver     : boolean = false;
    18.  
    19. private var flashOnOff          : boolean = false;
    20. public  var flashLightGO        : GameObject;
    21. public  var flashSound          : AudioSource;
    22.  
    23. function Start () {
    24.     globalVars = GameObject.FindGameObjectWithTag("GameController").GetComponent(GlobalVars);
    25.     localVars = playerRef.GetComponent(LocalVars);
    26.    
    27.     anim = playerRef.GetComponent(Animator);
    28.     hash = playerRef.GetComponent(HashIDsPlayer);
    29.    
    30.     currentHealthValue = globalVars.healthPickupGetSet;
    31.     currentGlowValue = globalVars.healthPickupGetSet;
    32.    
    33.     //Setup coherentUI
    34.     m_View = GetComponent(typeof(CoherentUIView)) as CoherentUIView;
    35.     m_View.Listener.ReadyForBindings += HandleReadyForBindings;
    36. }
    37.  
    38. function Update () {
    39.     GuiCountDownSet(globalVars.globalTimeGuiValue);
    40.     GuiAllSeeingSet(globalVars.allSeeGuiGetSetValue);
    41.     GuiHealthBarSet(globalVars.healthPickupGetSet);
    42.    
    43.     //Set doubleSpeed gui To charged
    44.     if(globalVars.speedPickupGetSet == 1){
    45.         globalVars.speedPickupGetSet = 2;
    46.         GuiDoubleSpeedSet();
    47.     }
    48.    
    49.     //Call gui screenGlow function
    50.     GuiScreenGlowSet(globalVars.healthPickupGetSet);
    51.    
    52.     //Call gui NextRound/GameOver fucntion
    53.     GuiRoundGameOver(globalVars.healthPickupGetSet);
    54. }
    55.  
    56.  
    57. function HandleReadyForBindings (frameId : int, path : String, isMainFrame:boolean){
    58.     if (isMainFrame)
    59.     {
    60.         /* binding this Functions so that JavaScript can call them */
    61.         m_View.View.BindCall("ToggleWalking", this.SetWalkingOnOff);
    62.         m_View.View.BindCall("ToggleRunning", this.SetRunningOnOff);
    63.        
    64.         m_View.View.BindCall("ToggleUnityAudio", this.ToggleGlobalAudio);
    65.    
    66.         m_View.View.BindCall("ToggleFlashlightOnOff", this.ToggleFlashlight);
    67.    
    68.         m_View.View.BindCall("ActivateDoubleSpeed", this.SetDoubleSpeedToOn);
    69.    
    70.     }
    71. }
    72.  
    73. ///////--------------Below are functions that JavaScript can call on Unity3D---------/////////
    74.  
    75. function SetWalkingOnOff(){
    76.     localVars.walking = !localVars.walking;
    77. }
    78. function SetRunningOnOff(){
    79.     localVars.running = !localVars.running;
    80. }
    81.  
    82. function ToggleGlobalAudio(){
    83.     if(AudioListener.volume > 0)
    84.         AudioListener.volume = 0;
    85.     else
    86.         AudioListener.volume = 1;
    87. }
    88.  
    89. function ToggleFlashlight(){
    90.     flashOnOff = !flashOnOff;
    91.     flashLightGO.SetActive(flashOnOff);
    92.     anim.SetBool(hash.flashBool, flashOnOff);
    93.     flashSound.Play();
    94. }
    95.  
    96. function SetDoubleSpeedToOn(){
    97.     if(globalVars.speedPickupGetSet == 2){ 
    98.         globalVars.speedPickupGetSet = 3;
    99.         globalVars.doubleSpeed = 1;
    100.     }
    101. }
    102.  
    103.  
    104. ///////--------------Below are functions that will call a JavaScript gui functions---------/////////
    105. //Set new gui timer if new time exist to avoid setting gui time multiple times per second
    106. function GuiCountDownSet(newTime:String){
    107.     if(newTime != currentTimeString){
    108.         m_View.View.TriggerEvent("SetGuiGlobalTimerValue", newTime);
    109.         currentTimeString = newTime;
    110.     }
    111. }
    112.  
    113. //Set new gui all seeing eye time value when new value exist to avoid setting it multiple times per second
    114. function GuiAllSeeingSet(newAllSeeValue:int){
    115.     if(newAllSeeValue != currentAlleSeeValue){
    116.         m_View.View.TriggerEvent("SetGuiAllSeeingTimerValue", newAllSeeValue);
    117.         currentAlleSeeValue = newAllSeeValue;
    118.     }
    119. }
    120.  
    121. //Set doubleSpeed gui To charged when doubleSpeed item picked up
    122. function GuiDoubleSpeedSet(){
    123.     m_View.View.TriggerEvent("SetGuiDoubleSpeedToFull");
    124. }
    125.  
    126. //Set new gui healthbar if new healthbar exist to avoid setting gui healthbar multiple times per second
    127. function GuiHealthBarSet(newHealth:int){
    128.     if(newHealth != currentHealthValue){
    129.         m_View.View.TriggerEvent("SetGuiHealthBarIcon", newHealth);
    130.         currentHealthValue = newHealth;
    131.     }
    132. }
    133.  
    134. //Set gui screen Glow
    135. function GuiScreenGlowSet(newHealthValue:int){
    136.     if(newHealthValue < currentGlowValue){
    137.         m_View.View.TriggerEvent("SetGuiDamageGlowOn");
    138.         currentGlowValue = newHealthValue;
    139.     }
    140. }
    141.  
    142. //Set gui NextRound/GameOver On
    143. function GuiRoundGameOver(newHealthValue:int){
    144.     if(newHealthValue <= 0  currentGameOver == false){
    145.         currentGameOver = true;
    146.         m_View.View.TriggerEvent("HideGui");
    147.         yield WaitForSeconds(1);
    148.         m_View.View.TriggerEvent("ShowRoundGameOver");
    149.         m_View.View.TriggerEvent("HideGui");
    150.     }
    151. }
    152.  
     
  5. Mr-Brent

    Mr-Brent

    Joined:
    Aug 20, 2013
    Posts:
    19
    Darkoo: You're calling the bindings before they're ready or set up. Put a check in the Update to make sure they're ready to go. It doesn't cause any real problems because after a frame or two, they are set up.
     
    Last edited: Sep 23, 2013
  6. Darkoo

    Darkoo

    Joined:
    Feb 4, 2013
    Posts:
    96
    Mr Brent: Awesome thank you!!

    Btw, everyone I am sorry you had to see my poor programming skills, I am new to all this stuff.
     
  7. rubicon_xing

    rubicon_xing

    Joined:
    Nov 30, 2012
    Posts:
    10
    I can imagine a whole host of reasons why it wouldn't, but is there any chance that CoherentUI will support <input type="file">?
     
  8. AnchoV

    AnchoV

    Joined:
    Jun 5, 2013
    Posts:
    17
    Hi,

    We already have this on the backlog, but unfortunately we can't promise when actually it will be ready. If you tell us what you are trying to achieve we might be able to suggest a reasonable work-around.
     
  9. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Hi,

    Are you using a script similar to our ObjectPicker.cs that detects whether the mouse is over a HUD element and tells the view to receive input?
    If so can you show its code?
    If you don't have this script and the "Supports Click Through" property is checked when the view never understands that it should take the user input.
    See our MenuAndHUD sample, especially the HUD view and the ObjectPicker script.

    By click on screen you mean outside of the view, but still inside in Unity3D or somewhere in the desktop?
    What properties are set in the inspector for the CoherentUIView component?
    Do you have anything else attached to that camera that might take the input?
    What version of Coherent UI you are using?
     
  10. rubicon_xing

    rubicon_xing

    Joined:
    Nov 30, 2012
    Posts:
    10
    I'm exploring alternatives to my file browser for loading local files. It's possible that the input type file won't fit the bill, as it is usually used to POST data server-side and simply won't make sense in this context.
     
  11. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    You can use the FileReader API for reading the files from the inputs,
    but it might be easier to use .Net to read the files and send directly bytes arrays to JavaScript with our API.
     
  12. rubicon_xing

    rubicon_xing

    Joined:
    Nov 30, 2012
    Posts:
    10
    I create my cameras at run-time, so I'm attaching the CoherentUI components at run-time. This is working well, except for a small change to CoherentUIView,cs. In the FlipY function, I had to add a check to see if the ViewRenderer isn't null, before setting the value.

    Code (csharp):
    1. if(m_Listener != null)
    2. {
    3.     if(m_Listener.ViewRenderer != null)
    4.     {
    5.         m_Listener.ViewRenderer.FlipY = ForceInvertY() ? !m_FlipY : m_FlipY;
    6.     }
    7. }
    I'm loading a start-up UI using a jQuery dialog. Again, everything is working well. When I'm done with the dialog, I use the dialog.close() function. The issue is that, when CoherentUIView is attached to the camera other UI elements aren't working. GUI buttons and GUI text work fine, but GUITextures do not. Neither does anything that ray-casts into the scene. This applies to cameras that do not have a CoherentUIView attached, as well. I've tried every variation of Click-through that I can think of and it's still not working.

    Here's the relevant portion of the camera class:
    Code (csharp):
    1.     CoherentUIView _uiView;
    2.     ManualBinding _binding;
    3.     InputForward _input;
    4.     void Awake()
    5.     {
    6.         _camera = gameObject.AddComponent<Camera>();
    7.         gameObject.AddComponent<GUILayer>();
    8.        
    9.         _uiView = gameObject.AddComponent<CoherentUIView>();
    10.         _binding = gameObject.AddComponent<ManualBinding>();
    11.         _input = gameObject.AddComponent<InputForward>();
    12.        
    13.         _uiView.FlipY = true;
    14.         _uiView.EnableBindingAttribute = true;
    15.         _uiView.IsTransparent = true;
    16.        
    17.         _uiView.Page = "coui://UIResources/Dialogs/startUp.html";
    18.     }
    Thoughts?
     
  13. rubicon_xing

    rubicon_xing

    Joined:
    Nov 30, 2012
    Posts:
    10
    I see now that if I set the CoherentUIView.ReceivesInput to false, the UI stops interrupting the scene interaction. This is fine for modal dialogs, but not so much for persistent UI. I'll dig into the MenuAndHUD examples and see if I can't find the solution in there.

    [Edit. The answer is, in fact, in the MenuaAndHUD example in ObjectPicker.cs.)
     
    Last edited: Sep 26, 2013
  14. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Whenever I try to use it on mac it always crashes.
     
  15. gridside

    gridside

    Joined:
    Jul 26, 2013
    Posts:
    97
    Thanks. That was my problem. So it's solved now. But i just noticed that uiresources folder stay outside of the assets folder even when i build and deploy my project. This html files are being accessible (and editable) by user. How can i solve this? It's because i'm using trial version?

    Thank you!
     
  16. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Hi,

    The reason for the UIResources folder to be outside of Assets is that Unity3D tries to compile any JavaScript file as UnityScript
    (because the extension is .js). Since plain JavaScript is not UnityScript the compilation fails and breaks the whole project.
    We haven't found a way/API to make Unity3D package the files during the build.
    In future versions we may start packing the uiresources folder in a some package format, but for now you have to do it yourself.
    If you want your uiresources to be not modifiable by the users, you can package them in a password protected or encrypted or signed archive.
    See our Sample05_ArchiveResource sample for how to implement custom file loading.
     
  17. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Can you give us some more information:
    What version of Coherent UI do you have?
    What version of Mac OS and Unity3D you are using?
    When it crashes - when hit the play button in the editor or on some other specific event?
     
  18. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Latest release appears to have some issues. Any idea what's going on?

    Code (csharp):
    1.  
    2. Non matching Profiler.EndSample (BeginSample and EndSample count must match)
    3. System.Object:__icall_wrapper_mono_array_new_specific(IntPtr, Int32)
    4. Coherent.UI.ViewListenerBase:GetHeaders(IntPtr) (at /Users/coherent/Desktop/PandoStatic/Pando/Coherent/UI/DotNET/swig/ViewListenerBase.cs:43)
    5. Coherent.UI.BrowserViewListener:SwigDirectorOnFinishLoad(Int32, String, Boolean, Int32, IntPtr) (at /Users/coherent/Desktop/PandoStatic/Pando/Coherent/UI/DotNET/swig/BrowserViewListener.cs:374)
    6. Coherent.UI.CoherentUI_NativePINVOKE:UISystem_Update(HandleRef)
    7. Coherent.UI.UISystem:Update() (at /Users/coherent/Desktop/PandoStatic/Pando/Coherent/UI/DotNET/swig/UISystem.cs:50)
    8. CoherentUISystem:Update() (at Assets/Standard Assets/Scripts/CoherentUI/CoherentUISystem.cs:714)
    9.  
    Code (csharp):
    1.  
    2. OutOfMemoryException: Out of memory
    3. Coherent.UI.ViewListenerBase.GetHeaders (intptr) (at /Users/coherent/Desktop/PandoStatic/Pando/Coherent/UI/DotNET/swig/ViewListenerBase.cs:43)
    4. Coherent.UI.BrowserViewListener.SwigDirectorOnFinishLoad (int,string,bool,int,intptr) (at /Users/coherent/Desktop/PandoStatic/Pando/Coherent/UI/DotNET/swig/BrowserViewListener.cs:374)
    5. (wrapper native-to-managed) Coherent.UI.BrowserViewListener.SwigDirectorOnFinishLoad (int,intptr,int,int,intptr) <IL 0x00039, 0x0010a>
    6. Coherent.UI.UISystem.Update () (at /Users/coherent/Desktop/PandoStatic/Pando/Coherent/UI/DotNET/swig/UISystem.cs:50)
    7. CoherentUISystem.Update () (at Assets/Standard Assets/Scripts/CoherentUI/CoherentUISystem.cs:714)
    8.  
    Edit: Nevermind, something went wrong with the install I guess. Completely deleted CoherentUI, re-imported, and re-installed it. Seams to be ok now!
     
    Last edited: Sep 28, 2013
  19. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Hi,

    Can you check that all Coherent UI dlls and CoherentUI_Host in your project have been properly updated via Right Click -> Properties -> Details?
    What url are you loading?
     
  20. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Ok, looks like I do have an issue. None of my bindings (BindCall) will work when I do Build and Run. Everything works fine using Play in the editor. The below stands out to me in the player log. Anyone else experiencing similar issue?

    Code (csharp):
    1.  
    2. Fallback handler could not load library REMOVED/Mono/CoherentUI_Native
    3. Fallback handler could not load library REMOVED/Mono/.\CoherentUI_Native
    4. Fallback handler could not load library REMOVED/Mono/CoherentUI_Native
    5. Fallback handler could not load library REMOVED/Mono/libCoherentUI_Native
    6. Fallback handler could not load library REMOVED/Mono/.\libCoherentUI_Native
    7. Fallback handler could not load library REMOVED/Mono/libCoherentUI_Native
    8.  
    Regardless of the above my UI does work. It loads my main menu fine, but none of my BindCall usages will work when I do Build and Run (they do work in editor!).
     
  21. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Hi,

    Are you building to a brand new folder?
    What is your version of Unity3D and to what platform you are exporting?
     
  22. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Yes, after each test I delete the build and rebuild it new again.

    4.2.1f4 and building to PC Standalone.

    Everything works perfectly in the Editor so it's really strange.
     
  23. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    If you are building for 64 bit, can you check that the following Dlls are the proper version:
    Project_Data/Managed/CoherentUINet.dll
    Project_Data/Plugins/CoherentUI64_Native.dll
     
  24. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    I'm not building to 64 bit, but CoherentUINet.dll and CoherentUI_Native.dll (non-64 bit version) are both present.

    Also figured out my binding issue. I've a usage problem with one of my bindings. Is there any way to cause CoherentUI to output JS errors in the view to the console/log?
     
  25. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    If you mean errors for calling .Net delegates from JavaScript, you can use
    Code (csharp):
    1.  
    2. engine.on('Error', console.log.bind(console, 'binding error:'));
    3.  
    If you mean JavaScript errors to Unity3D console/log you can use the following component:
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using Coherent.UI;
    4.  
    5. public class JavaScriptLog : MonoBehaviour {
    6.     void Start () {
    7.         var view = GetComponent<CoherentUIView>();
    8.         view.Listener.ScriptMessage += this.OnJavaScriptMessage;
    9.    
    10.     }
    11.    
    12.     void OnJavaScriptMessage(ViewListenerBase.MessageLevel level, string message, string sourceId, int line)
    13.     {
    14.         var log = string.Format("JavaScript Log {0}:{1} {2}", sourceId, line, message);
    15.         switch (level)
    16.         {
    17.         case ViewListenerBase.MessageLevel.ML_ERROR:
    18.             Debug.LogError(log);
    19.             break;
    20.         case ViewListenerBase.MessageLevel.ML_WARNING:
    21.             Debug.LogWarning(log);
    22.             break;
    23.         default:
    24.             Debug.Log(log);
    25.             break;
    26.         }
    27.     }
    28. }
    29.  
     
  26. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Awesome, thank you. Was able to find my problem. Just a JS error in my UI files.
     
  27. Aiursrage2k

    Aiursrage2k

    Joined:
    Nov 1, 2009
    Posts:
    4,835
    Cohernet version 1.5.1
    mac - os x version 10.6.8
    unity 3.5.5
    It crashes whenever the cohernet UI view tries to awaken.
     

    Attached Files:

    Last edited: Sep 28, 2013
  28. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Hi Aiursrage2k,

    Coherent UI 1.5.1 doesn't support Mac OS X 10.6.
    Coherent UI 1.5.2 has support for Mac OS X 10.6 and it is already in the Asset Store If you are using
    an evaluation version or please write to us at support@coherent-labs.com and we'll send you the latest release.
     
  29. Mr-Brent

    Mr-Brent

    Joined:
    Aug 20, 2013
    Posts:
    19
    I have this exact same problem. The profiler error only occurs when the profiler is open, and I get the second error when I actually push to iOS and try to run it on my iPad. My error also says Out of Memory, but Xcode isn't giving me a stack trace. Having exactly the same two errors though seems more than a coincidence.

    I JUST did a fresh install though, so I'm not sure what my recourse is.

    Unity for Mac: 4.2.1f4
    Mac OSX: 10.8.5

    $Screen Shot 2013-09-28 at 1.02.55 PM.png
     
    Last edited: Sep 28, 2013
  30. nikxio

    nikxio

    Joined:
    Oct 30, 2012
    Posts:
    69
    Hi,
    We fixed a possible out-of-memory exception for the iOS build in the latest version (1.5.2.0). If you're using a prior one, please try upgrading.
     
  31. Mr-Brent

    Mr-Brent

    Joined:
    Aug 20, 2013
    Posts:
    19
    Just did a full re-install, same crash once I publish. Works fine in the editor as long as I don't bring up the Profiler.
     
  32. nikxio

    nikxio

    Joined:
    Oct 30, 2012
    Posts:
    69
    We will investigate the issue. Does the bug always manifest itself or just some times? Also, does the MobileInput sample work for you or it out-of-mems as well? If you could send us a project that reproduces the problem or instructions how to make one that would help us greatly.
     
  33. Mr-Brent

    Mr-Brent

    Joined:
    Aug 20, 2013
    Posts:
    19
    The mobile input test works just fine... so it must be something I'm doing. I'll dig in deeper and see what I can find.
     
  34. Mr-Brent

    Mr-Brent

    Joined:
    Aug 20, 2013
    Posts:
    19
    So originally I had not imported the Samples, as I already knew how to use Coherent, but once I imported them, everything worked fine. Perhaps there's something in the Samples folders that is required? This also fixed the in-editor Profiler issue. All I see in those files that looks relevant is /Samples/Scenes/Sample_MobileInput/Editor/. In there are two ProjectFixer scripts, which sound ominous.

    Either way, back to the game dev, thanks for the help!

    EDIT: The problem came back, but I figured out what caused it. Having Intercept All Events checked is both the cause of the profiler issue and the Xcode crash.
     
    Last edited: Sep 29, 2013
  35. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Is it possible to auto scale the UI? I know by default the resolution scales automatically, but I'd like the UI to get smaller or later (I guess UI aspect ratio?) based off the window resolution. Is that possible from Unity or is it best to use CSS/JS for this? The idea for example is to prevent UI elements from going off screen if the window resolution is too low. Without something like this you end up having to design your UI for 800x600 to accommodate the smallest sizes.
     
    Last edited: Sep 29, 2013
  36. Mr-Brent

    Mr-Brent

    Joined:
    Aug 20, 2013
    Posts:
    19
    @Krileon The Mobile Input demo I've been looking at actually does some of that. It does it by scaling elements / font size with regards to window size in the javascript. If you do that and use "em" measurements for stuff, it should be pretty easy to scale your UI.
     
  37. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Ah, will check that demo out. I don't know why, but was hoping it just had a feature to scale it automatically for some crazy reason, lol. Figured using relative sizes would work, but concerned how well it's going to do for my precision placed absolute elements; guess I'll find out.

    I suppose what I'm asking is an auto zoom in/out feature to keep the scale of the UI with the window resolution. So for example as the resolution gets smaller it zooms out to make the UI smaller so they still fit. Almost like the zoom feature every browser has.

    I guess there's always responsive design, but that's a massive pain trying to support the various resolutions, testing them all, etc.. looking for a simple solution that doesn't require me to redo my entire CSS. Plus I need pixel accuracy when working with absolute positioning.

    Edit: Looks like the below usage works, but then the resolution goes to crap. I'll keep playing with some of the experimental CSS3 usages and see if I can find something usable.

    Code (csharp):
    1.  
    2. -webkit-transform: scale(0.8);
    3.  
    Ok, just using zoom seams to work best to keep resolution crisp while making it smaller/bigger. The below works.

    Code (csharp):
    1.  
    2. zoom: 0.5;
    3.  
    That would make it 50% smaller for example. Apply it to the body element and it'll scale the entire page. Next step is some simple JS to set this based off the window resolution. For that you'd probably need to determine what the default height and width would be to calculate the percentage you'd want it to scale from.
     
    Last edited: Sep 30, 2013
  38. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Hi,

    CSS3 has some new units that help achieve automatic scaling

    1vw: 1% of viewport width
    1vh: 1% of viewport height
    1vmin: 1vw or 1vh, whatever is smallest
    1vmax: 1vw or 1vh, whatever is largest

    You can use them as you are used to pixels, but they are "scalable" pixels, so you'll achieve the effect you want.
    Here is some more info on that:
    http://dev.opera.com/articles/view/css-viewport-units/
     
  39. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Indeed it seems that "Intercept All Events" is broken in the new release, we are going to fix it or provide some work around as soon as possible.
     
  40. PTrefall

    PTrefall

    Joined:
    Nov 5, 2012
    Posts:
    10
    Hi, I've tried to apply a Coherent UI View to an NGUI element, and it seems to not work very well, since NGUI seems to work a bit different with materials and renderer than, say, a Plane would. Any news on this example? I'd prefer to have a coherent ui view on a surface who's scaling is controlled by NGUI. Thank you. With MathJax via Coherent UI I can finally render math in Unity3D properly.
     
  41. Krileon

    Krileon

    Joined:
    Oct 30, 2012
    Posts:
    642
    Viewports do not work on desktop browsers. I'm designing for multiple screen resolutions on desktop (think of it like expanding and shrinking your browser window). The best solution I can see is to continue to use zoom. There's also the scale transform, but it's not as good as zoom.

    It maybe worth considering, if possible, a setting to enable to auto scale (it could be as simple as handling the webkit zoom automatically) in a future release. This way we could design once and it fit multiple resolutions. Seams like it'd be a pretty cool feature.
     
  42. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    I see. It will be a cool feature, we'll see how would be best to add it to Coherent UI
     
  43. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Unfortunately, the sample is in the backlog for the current sprint, but it is not ready yet.
    Can you describe what doesn't work?
     
  44. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Fix for the "Intercept All Events" crash

    Since it will be much faster than to make a new release and wait for the Asset Store to approve it, I am posting how to fix the "Intercept All Events"
    functionality here.

    To fix the crash - open coherent.js for you view and change the line:
    Code (csharp):
    1.  
    2. var allArguments = ['all'].concat(arguments);
    3.  
    to:
    Code (csharp):
    1.  
    2. var allArguments = Array.prototype.concat.apply(['all'], arguments);
    3.  
    The reason for the crash is that reporting binding errors from .Net back to JavaScript is not implemented yet and it caused an exception to be thrown
    in a not appropriate moment.

    We are going to implement this for the one of the next releases.
     
  45. Mr-Brent

    Mr-Brent

    Joined:
    Aug 20, 2013
    Posts:
    19
    It seems that at least with the mobile version, Touch events stay with whatever platform they started on. So if you start a touch in the game, then drag over the ui, it's still only the game getting events.

    My issue is that I'm opening a radial menu over a unit that I've held down on, and I wish to drag out from there onto an action, but since the touch started in the game, the UI isn't getting it. Is there a way around this, other than just recognizing situations like this and sending the touch info through the engine?
     
  46. DimitarT

    DimitarT

    Joined:
    Apr 8, 2013
    Posts:
    99
    Hi,

    Coherent UI for mobile is creating a separate window for the view. I couldn't find an API for transferring touch events between windows, so the only option seems to go through the engine. Drag-and-Drop support between the UI and the game is actually a planned feature for Coherent UI, but we haven't got to it yet.
     
  47. jdesantos

    jdesantos

    Joined:
    May 24, 2013
    Posts:
    304
  48. AnchoV

    AnchoV

    Joined:
    Jun 5, 2013
    Posts:
    17
    Hi guys,

    We are glad to show you our new video tutorial - Game and UI communication in Unity3D in which we take a look at the binding mechanisms that Coherent UI provides for Unity3D. We explore the different ways to pass data from JavaScript to C# and vice versa. The example shown demonstrates how easy it is to pass messages back and forth between your game and the UI. You’ll get to know the basics of the binding which will allow you to create rich and powerful game interfaces.

    Enjoy it :)


     
  49. Mr-Brent

    Mr-Brent

    Joined:
    Aug 20, 2013
    Posts:
    19
    Thanks for the quick response!
     
  50. gridside

    gridside

    Joined:
    Jul 26, 2013
    Posts:
    97
    Thanks for the video AnchoV