1 Replies - 295 Views - Last Post: 24 June 2013 - 01:56 PM Rate Topic: -----

#1 TrewSx  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 50
  • Joined: 07-June 12

Loop thru images while pressing GUI.Button - UnityScript

Posted 24 June 2013 - 08:34 AM

Hello there,

I am trying to create right and left GUI.Buttons and in the middle is another GUI.Button which is displaying set of images. If you press right GUI.Button, you will loop forward thru your images and if you press left GUI.Button you will loop back thru images set in the Texture2D[] variable.

Now my problem, i made the right button work, when i click on it next image is being displayed, but i cannot do the loop back for the left button. Could anyone help me with this please. I am really stuck.

Inside the Update function I am invoking TrackWindow function

and in my OnGUI I am displaying my Left/Right GUI.Buttons

Here is a sample of my code

    function TrackWindow(trackWindowID) {    	
        for(var cnt : int = 0; cnt < 1; cnt++) {
            var offset : int = trackWindowRect.width * 0.01;
    	    var widthSpacing : int = trackWindowRect.width * 0.02;    
    	    
    	    if (GUI.Button(new Rect(offset + (cnt * (trackWindowRect.width * .98f + widthSpacing)), 20, (trackWindowRect.width * .98f) , trackWindowRect.height * .88f), textures[i])) {
            
                invertClick = !invertClick;
    	  		
    	        if (invertClick) {    
    			    
    	            if (i < textures.Length-1) {
    						   
    	                i++;
    				   
    	            }else {
    			    
    	                i = 0;
    	                CancelInvoke("TrackWindow");
    	            }  									 			 			
    	        }
            }   	
         }//End FOR Loop
    }//End function
    
    
    //Move track to the right
        if (GUI.Button(new Rect(Screen.width * 0.75 ,Screen.height * 0.77,100,100)," Next Track ")) {
        	
        	invertClickRightSide = true;
        	
        	if (invertClickRightSide) {
    	    	
    	    	if (i < textures.Length-1) {
    	    	
    	    		i++;
    	    	}else {
    	    	
    	    		i = 0;
    	    		CancelInvoke("TrackWindow");
    	    	}
    	    }
        } 



Is This A Good Question/Topic? 0
  • +

Replies To: Loop thru images while pressing GUI.Button - UnityScript

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Loop thru images while pressing GUI.Button - UnityScript

Posted 24 June 2013 - 01:56 PM

1. Please confirm the language and development environment you are using. Is it Unity?
2. Please specify how it is 'not working'. Do the images freeze when you press left for instance?

This post has been edited by ButchDean: 24 June 2013 - 01:57 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1