Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AR_Rizvi · Sep 09, 2013 at 07:00 AM · guibuttonsliding

Sliding Gui auto button generator... help

Hi Guys... i am trying to make a sliding menu which contains the auto generated buttons i achieve both things but in separate ways or in separate scripts and i am really not getting how to merge both functionalities becoz both are doing different functions on gui

What i want is to make a sliding Gui in which it contains my buttons which my script is creating

here is the code on my auto button generator

 #pragma strict
 var player : GameObject;
 
 var tagObjs : GameObject[];
 var tagObjsRam : GameObject[];
 var names = new Array(); 
 //var position : GameObject[];
 private var activeChild : GameObject;
 private var LTInfoWindow : Rect ;
 //var btnName : String = new Array ();
 private var btnName:Array = new Array();
 private var scrollPosition : Vector2 = Vector2.zero;
 private var winLenght : int;
 private var show_pos : boolean;
 private var hideShowBtnWidth : int;
 
 function Start () 
 {
     hideShowBtnWidth =100;
 //    tagObjsRam = GameObject.FindGameObjectsWithTag("PlayerPos");
      
     tagObjs = OrderByName("PlayerPos");
     
     
     for (var i = 0; i <tagObjs.Length; i++ )
     {
         btnName.push(tagObjs[i].gameObject.name);
     } 
     //Debug.Log("btnName: "+btnName.length);
     //Debug.Log("btnName[0]: "+btnName[0]);
 
 }
 
 function Update () {
 winLenght = btnName.length * 100;
 if(winLenght > Screen.width - hideShowBtnWidth)
     winLenght = Screen.width - hideShowBtnWidth;
 LTInfoWindow = Rect (hideShowBtnWidth, Screen.height-70,winLenght,70);
 
 //Debug.Log("tagObjs.length: "+tagObjs.length);
 
 //if(Input.GetKeyUp(KeyCode.Y))
 //{
 //    
 //}
 
 
 }
 function OnGUI () 
 {
 
 
 if(show_pos)
         InfoWindow();
 
  if (GUI.Button(Rect(0,Screen.height-70,hideShowBtnWidth,70),"Locations"))
 {
      
      show_pos = !show_pos;
 } 
             
 
     
 }
 
 function InfoWindow()
 {
     LTInfoWindow = GUI.Window (11, LTInfoWindow, InfoDislay, "Player Shifting");
     
 }
 
 function InfoDislay(windowID : int)
 {
     
     scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(winLenght-20), GUILayout.Height(45));
     GUILayout.BeginHorizontal();
     
     for(var i = 0; i<btnName.length; i++)
 
         {
             if (GUILayout.Button(btnName[i].ToString())) 
             {
                     setlayer();
                     activeChild.transform.position = tagObjs[i].gameObject.transform.position;
                     activeChild.transform.eulerAngles.y =tagObjs[i].gameObject.transform.eulerAngles.y;
 //                    show_pos = !show_pos;
             }
         }    
 
      
     GUILayout.EndHorizontal(); 
     GUILayout.EndScrollView();
     GUI.DragWindow ();
 }
 function setlayer()
 {
     for (var child : Transform in player.transform)
     {
         if(child.active)
             activeChild = child.transform.gameObject;
     } 
 }
 
 function OrderByName (tag) : GameObject[]
 {
     var gos : GameObject[];
     var names = new Array(); 
     var finals = new Array();  
     gos = GameObject.FindGameObjectsWithTag(tag); 
     for (var go : GameObject in gos)  { 
         names.Push(go.name);
     }
     names.Sort();
     for (var name : String in names)  { 
         for (var go : GameObject in gos)  { 
             if(go.name==name){
                 finals.Push(go);
             }
         }
     }
     return finals.ToBuiltin(GameObject);    
 }
 

its working perfectly

and here's what i achive so far in Gui sliding script which slides the Gui skin on the Space button...

 var MyBoxLeft = -200.0;
 
 var icon : Texture; var icon2 : Texture; var blankSkin : GUISkin;
 
 function OnGUI () { GUI.skin = blankSkin; var tBoxRect = new Rect(MyBoxLeft, 20.0, 220, 720); var tButtonRect = new Rect(MyBoxLeft, 160.0, 120, 30); var tBoxArt = new Rect(MyBoxLeft, 200.0, 120, 120);
 
 GUI.Box(tBoxRect, icon); GUI.Button(tButtonRect, "Click"); GUI.Box(tBoxArt, icon2); }
 
 function Update () {
 
 if (Input.GetKeyDown("space")) { AnimateBox(); }
 
 }
 
 function AnimateBox () {
 
 if (MyBoxLeft == -200.0) {
 
     while (MyBoxLeft < 20.0) {
     MyBoxLeft+=5.0;
     yield;
     }
 
 } else if (MyBoxLeft == 20.0) {
 
     while (MyBoxLeft > -200.0) {
     MyBoxLeft-=5.0;
     yield;
     }
 
 }
 
 }

Thanks Guys realy need help in this .... AR

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I make a gui with buttons pop up in javasript? 1 Answer

GUI.Label positioning for many device resolutions 1 Answer

Resolutions 1 Answer

How to get Rect from scene Button ? 1 Answer

Generating tooltips for multiple buttons. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges