Search Unity

Cannot switch to fullscreen via Javascript

Discussion in 'Scripting' started by ahmetDP_1, Feb 2, 2011.

  1. ahmetDP_1

    ahmetDP_1

    Joined:
    Sep 23, 2010
    Posts:
    113
    Hi,

    ı have a web player application with two objects; one is for switching to fullscreen and the other is for reverting back to window mode. Both actions are in OnMouseDown() methods of these objects. Code is simple as
    Code (csharp):
    1. Screen.fullScreen = true/false
    . Everything works fine with this.

    Now, I wanted to take the triggering object out from the Unity App into the HTML page, and wanted to switch to full screen via a javascript call ( SendMessage ). Javascript event is triggered, message ( parameter to the function ) is delivered into Unity App, but the full screen is not working. I tried debugging almost every line, but to no avail. Any idea what's going on here, or what am I doing wrong?

    an object to switch full screen, say a Cylinder
    Code (csharp):
    1. void OnMouseDown ()
    2.     {
    3.         Screen.fullScreen = true;
    4.     }
    another object to revert back to window mode, say a Cube:
    Code (csharp):
    1. void OnMouseDown ()
    2.     {
    3.         Screen.fullScreen = false;
    4.     }
    In case two, for javascript trigger: an empty game object with name LevelManager:
    Code (csharp):
    1. public void SwitchFullscreen(string s)
    2.  
    3.     {
    4.  
    5.         s = s.ToLower();
    6.  
    7.        
    8.  
    9.         debugMsg = "";
    10.  
    11.         debugMsg += "LM : " + s;
    12.  
    13.        
    14.  
    15.         if( s.Equals("true") ) {
    16.  
    17.             debugMsg += " t "; [COLOR="lime"]// the code reaches to this line[/COLOR]
    18.  
    19.             Screen.fullScreen = true;
    20.  
    21.         }
    22.  
    23.         else if( s.Equals("false") ) {
    24.  
    25.             debugMsg += " f "; [COLOR="lime"]// the code reaches to this line[/COLOR]
    26.  
    27.             Screen.fullScreen = false;
    28.  
    29.         }
    30.  
    31.         else {
    32.  
    33.             debugMsg += " ? ";
    34.  
    35.             Screen.fullScreen = false;
    36.  
    37.         }
    38.  
    39.     }
     
  2. ahmetDP_1

    ahmetDP_1

    Joined:
    Sep 23, 2010
    Posts:
    113
    no ideas yet?
    hmm, not from here either.
     
  3. ahmetDP_1

    ahmetDP_1

    Joined:
    Sep 23, 2010
    Posts:
    113
  4. acropole

    acropole

    Joined:
    Aug 13, 2009
    Posts:
    171
    Check if OnMouseDown is called. It looks like OnMouseDrag is called in place of.
     
  5. ahmetDP_1

    ahmetDP_1

    Joined:
    Sep 23, 2010
    Posts:
    113
    Thanks for the answer. You mean somewhere else other than the codes I gave above?

    Anyway, I'll look into that. Is it Down or Drag you are suspicious about?