Search Unity

Functions OnMouseOver , OnMouseExit and OnMouseDown on iPhone ?

Discussion in 'iOS and tvOS' started by KeepTrying, Feb 23, 2011.

  1. KeepTrying

    KeepTrying

    Joined:
    Feb 23, 2011
    Posts:
    119
    Hi folks
    Why these functions don`t work on iPhone or other touch devices ?
    I trying around a week to make it happens but no luck whats wrong with my code ?
    Look sample code

    startnewgame.js

    function Start(){
    guiText.material.color=Color.yellow;
    }
    function OnMouseOver () {
    guiText.material.color=Color.green;
    }

    function OnMouseExit(){
    guiText.material.color=Color.yellow;
    }

    function OnMouseDown(){
    PlayerPrefs.SetInt("falllevel", 0);
    Application.LoadLevel(Application.loadedLevel);
    }
     
    Last edited: Feb 23, 2011
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    This is by design, indeed the scripting reference pages for OnMouseEnter, etc, say that the functions have no effect on the iPhone.
     
  3. KeepTrying

    KeepTrying

    Joined:
    Feb 23, 2011
    Posts:
    119
    My code is ready to go only i need to learn is how to (CHANGE OnMouse events) to implement this metod :

    if (Input.touchCount > 0)
    {
    Touch touch = Input.GetTouch(0);
    yourCode();
    }

    OnMouse is not compatible with iOS >>>>>>>> Look more of my code with the <damn> OnMouse Events i hate that XD

    var lock:Texture;

    var loadlevel:int;

    private var zoom:boolean=false;

    function OnMouseOver () {
    zoom=true;
    if(transform.localScale.x <= 0.87 renderer.material.mainTexture != lock){
    transform.localScale.x += 0.8 * Time.deltaTime;
    transform.localScale.y += 0.8 * Time.deltaTime;
    }
    }

    function OnMouseExit(){
    zoom=false;
    }

    function OnMouseDown(){
    if(renderer.material.mainTexture != lock){
    Application.LoadLevel(loadlevel);
    }
    }


    function Update(){
    if(!zoom renderer.material.mainTexture != lock){
    if(transform.localScale.x >= 0.25){
    transform.localScale.x -= 0.2 * Time.deltaTime;
    transform.localScale.y -= 0.2 * Time.deltaTime;
    }
    }
    }

    I need to join the function Update with that code ?


    if (Input.touchCount > 0)
    {
    Touch touch = Input.GetTouch(0);
    yourCode();
    }


    Because 2 function Update is not allowed Right ?

    See more_______________________________________________________________________________

    This is my production code___________________________________________


    var textura:Texture2D;
    var texturaover:Texture2D;
    function OnMouseOver () {
    guiTexture.texture=texturaover;
    }
    function OnMouseExit(){
    guiTexture.texture=textura;
    }
    function OnMouseDown(){
    Application.LoadLevel(Application.loadedLevel+1);
    }

    This is the code with the modifications ! _________________________________

    var textura:Texture2D;
    var texturaover:Texture2D;

    if (Input.touchCount > 0)
    {
    Touch touch = Input.GetTouch(0);
    guiTexture.texture=texturaover;
    }

    if (Input.touchCount > 0)
    {
    Touch touch = Input.GetTouch(0);
    guiTexture.texture=textura;
    }

    if (Input.touchCount > 0)
    {
    Touch touch = Input.GetTouch(0);
    Application.LoadLevel(Application.loadedLevel+1);
    }

    Unity say ERROR > Assets/scripts/nextlevel.js(14,58): UCE0001: ';' expected. Insert a semicolon at the end.

    Many thanks in advance man !!!!!!!!

     
    Last edited: Feb 26, 2011