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 Flafla2 · Jan 11, 2011 at 11:07 PM · guidragwindow

Can't Drag GUI.Window's!!!

Now, I have a massive GUI script that is working so far, but the windows are not draggable at all. What I mean is, the windows are visible, and when you click their title bar the border turns white like it is supposed to, but I simply can't drag the windows around. Here is the code:

var doWindowWall : boolean = false; var doWindowMembrane : boolean = false; var doWindowCytoplasm : boolean = false; var doWindowRibosome : boolean = false; var doWindowER : boolean = false; var doWindowGolgi : boolean = false; var doWindowMitoC : boolean = false; var doWindowLysosomes : boolean = false; var doWindowMicTF : boolean = false; var doWindowCilFla : boolean = false; var doWindowNucleus : boolean = false; var doWindowVacs : boolean = false; var doWindowChlorpl : boolean = false; var doWindowChrompl : boolean = false; var doWindowVirus : boolean = false;

var iPadGladiator : Texture2D; var iPadGladiatorHighlight : Texture2D; var iPad2ndtexture : Texture;

private var wallRect = Rect (110,10,350,200); private var membraneRect = Rect (110,10,350,200); private var cytoRect = Rect (110,10,500,500); private var ribsRect = Rect (110,10,350,200); private var eRRect = Rect (110,10,500,500); private var golgiRect = Rect (110,10,350,200); private var mitoRect = Rect (110,10,350,200); private var lysoRect = Rect (110,10,350,200); private var micTFRect = Rect (110,10,500,500); private var cilFlaRect = Rect (120,10,500,500); private var nucleusRect = Rect (110,10,500,500); private var vacsRect = Rect (110,10,500,500); private var chlorplRect = Rect (110,10,350,200); private var chromplRect = Rect (110,10,350,200); private var virusRect = Rect (110,10,500,500);//variables

function OnGUI () { var iPad = GameObject.Find("iPad");

 GUI.Box(Rect (0,0,110,300), "");
 doWindowWall = GUI.Toggle (Rect (0,5,100,20), doWindowWall, "Cell Wall");
 doWindowMembrane = GUI.Toggle (Rect (0,20,100,20), doWindowMembrane, "Cell Membrane");
 doWindowCytoplasm = GUI.Toggle (Rect (0,35,100,20), doWindowCytoplasm, "Cytoplasm");
 doWindowRibosome = GUI.Toggle (Rect (0,50,100,20), doWindowRibosome, "Ribosomes");
 doWindowER = GUI.Toggle (Rect (0,65,100,20), doWindowER, "ER");
 doWindowGolgi = GUI.Toggle (Rect (0,80,100,20), doWindowGolgi, "Golgi Bod.");
 doWindowMitoC = GUI.Toggle (Rect (0,95,100,20), doWindowMitoC, "Mitochondria");
 doWindowLysosomes = GUI.Toggle (Rect (0,110,100,20), doWindowLysosomes, "Lysosomes");
 doWindowMicTF = GUI.Toggle (Rect (0,125,100,20), doWindowMicTF, "Micro T/F");
 doWindowCilFla = GUI.Toggle (Rect (0,140,100,20), doWindowCilFla, "Cilia+Flag.");
 doWindowNucleus = GUI.Toggle (Rect (0,155,100,20), doWindowNucleus, "Nucleus");
 doWindowVacs = GUI.Toggle (Rect (0,170,100,20), doWindowVacs, "Vacuoles");
 doWindowChlorpl = GUI.Toggle (Rect (0,185,100,20), doWindowChlorpl, "Chloroplasts");
 doWindowChrompl = GUI.Toggle (Rect (0,200,100,20), doWindowChrompl, "Chromoplasts");
 doWindowVirus = GUI.Toggle (Rect (0,215,100,20), doWindowVirus, "Virus");

 if (GUI.Button(Rect(0,310,50,50), "Reset")) {
     iPad.transform.rotation = Quaternion.identity;
     iPad.transform.Rotate(0, 90, 270);
 }


 if (doWindowWall) {
     GUI.Window (0, wallRect, DoWindowWall, "The Cell Wall");
 }
 if (doWindowMembrane) {
     GUI.Window (1, membraneRect, DoWindowMembrane, "The Cell Membrane");
 }
 if (doWindowCytoplasm) {
     GUI.Window (2, cytoRect, DoWindowCytoplasm, "The Cytoplasm");
 }
 if (doWindowRibosome) {
     GUI.Window (3, ribsRect, DoWindowRibosome, "Ribosomes");
     iPad.animation.Play("BoomBoom");
 }
 if (doWindowER) {
     GUI.Window (4, eRRect, DoWindowER, "The ER");
 }
 if (doWindowGolgi) {
     GUI.Window (5, golgiRect, DoWindowGolgi, "Golgi Bodies");
 }
 if (doWindowMitoC) {
     GUI.Window (6, mitoRect, DoWindowMitoC, "Mitochondria");
 }
 if (doWindowLysosomes) {
     GUI.Window (7, lysoRect, DoWindowLysosomes, "Lysosomes");
 }
 if (doWindowMicTF) {
     GUI.Window (8, micTFRect, DoWindowMicTF, "Microtubules/Mictrofilaments");
 }
 if (doWindowCilFla) {
     GUI.Window (9, cilFlaRect, DoWindowCilFla, "Cilia+Flagella");
 }
 if (doWindowNucleus) {
     GUI.Window (10, nucleusRect, DoWindowNucleus, "The Nucleus");
 }
 if (doWindowVacs) {
     GUI.Window (11, vacsRect, DoWindowVacs, "Vacuoles");
 }
 if (doWindowChlorpl) {
     GUI.Window (12, chlorplRect, DoWindowChlorpl, "Chloroplasts");
 }
 if (doWindowChrompl) {
     GUI.Window (13, chromplRect, DoWindowChrompl, "Chromoplasts");
     iPad.animation.Play("BoomBoom");
 }
 if (doWindowVirus) {
     GUI.Window (14, virusRect, DoWindowVirus, "A Virus");
 }

}

function Update () { var iPad = GameObject.Find("iPad"); var rotatescript = iPad.GetComponent(Rotatescript); if (doWindowWall) { iPad.transform.Rotate(15 * Time.deltaTime, 0, 0); } if (doWindowMembrane) { //doWindowMembrane = false; iPad.transform.rotation = Quaternion.identity; iPad.transform.Rotate(0, 90, 0); } if (doWindowCytoplasm) { //None. Expressed as a picture. } if (doWindowRibosome) {

 }
 if (doWindowER) {
     //None.  Expressed as a picture
 }
 if (doWindowGolgi) {
     iPad.transform.Rotate(15 * Time.deltaTime, 0, 0);
 }
 if (doWindowMitoC) {
     iPad.transform.Rotate(15 * Time.deltaTime, 0, 0);
 }
 if (doWindowLysosomes) {
     iPad.transform.Rotate(15 * Time.deltaTime, 0, 0);
 }
 if (doWindowMicTF) {
     //None.  Expressed as a picture.
 }
 if (doWindowCilFla) {
     //None.  Expressed as a picture.
 }
 if (doWindowNucleus) {
     //None.  Expressed as a picture
 }
 if (doWindowVacs) {
     //None.  Expressed as a picture
 }
 if (doWindowChlorpl) {
     iPad.transform.Rotate(15 * Time.deltaTime, 0, 0);
 }
 if (doWindowChrompl) {
     //None - Animation
 }
 if (doWindowVirus) {
     //None.  Expressed as a picture.
 }

}

function DoWindowWall (windowID : int) { GUI.Label (Rect (10,20,320,170), "The Cell Wall ~ Casing of the iPad"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowMembrane (windowID : int) { GUI.Label (Rect (10,20,320,170), "The Cell Membrane ~ The Plug on the iPad"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowCytoplasm (windowID : int) { GUI.Label (Rect (10,20,320,170), "The Cytoplasm ~ Circuit Board"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowRibosome (windowID : int) { GUI.Label (Rect (10,20,320,170), "Ribosomes ~ App Store(Proteins ~ Apps)"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowER (windowID : int) { GUI.Label (Rect (10,20,320,170), "The ER ~ Wires on the Circuit Board"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowGolgi (windowID : int) { GUI.Label (Rect (10,20,320,170), "The Golgi Apparatus ~ Sync Wire"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowMitoC (windowID : int) { GUI.Label (Rect (10,20,320,170), "Mitochondria ~ Charging Wire"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowLysosomes (windowID : int) { GUI.Label (Rect (10,20,320,170), "Lysosomes ~ Program to Delete Files"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowMicTF (windowID : int) { GUI.Label (Rect (10, 20, 480, 350),iPadGladiatorHighlight); GUI.Label (Rect (10,270,320,170), "Microtubules and Microfilaments ~ Arms and Legs of Owner"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowCilFla (windowID : int) { GUI.Label (Rect (10, 20, 480, 350),iPadGladiator); GUI.Label (Rect (10,270,320,170), "Cilia and Flagella ~ The iPad's Owner"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowNucleus (windowID : int) { GUI.Label (Rect (10,20,320,170), "The Nucleus ~ The A4 Chip"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowVacs (windowID : int) { GUI.DragWindow (Rect (0,0,10000,10000)); GUI.Label (Rect (10,20,320,170), "Vacuoles ~ Flash Memory(Data ~ Materials)"); } function DoWindowChlorpl (windowID : int) { GUI.Label (Rect (10,20,320,170), "Chloroplasts ~ The Solar Powered iPad Charger"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowChrompl (windowID : int) { GUI.Label (Rect (10,20,320,170), "Chromoplasts ~ The iPad's Screen"); GUI.DragWindow (Rect (0,0,10000,10000)); } function DoWindowVirus (windowID : int) { GUI.Label (Rect (10,20,320,170), "Viruses ~ A jailbreaker on the iPad"); GUI.DragWindow (Rect (0,0,10000,10000)); }

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

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by Bampf · Mar 21, 2011 at 11:03 AM

I think the problem is that GUI.Window is returning a Rect, and your script is ignoring it.

(This would be similar to the way the GUI sliders pass back a new value, which you must save and use as the value the next time you call the slider function. If you don't, you are just displaying the original value again.)

So instead of

GUI.Window (13, chromplRect, DoWindowChrompl, "Chromoplasts");

Try

chromplRect = GUI.Window (13, chromplRect, DoWindowChrompl, "Chromoplasts");
Comment
Add comment · Show 3 · Share
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
avatar image Bunny83 · Apr 02, 2011 at 01:39 AM 1
Share
  • BTW: if you want to make the whole window draggable just use GUI.DragWindow() without any parameter.

avatar image Joshua · Apr 14, 2011 at 01:33 AM 0
Share

Thanks! (8 more to go.. :p)

avatar image Dealzu-The-Wikid · Jun 30, 2014 at 10:37 PM 0
Share

Yay!! Thanks for this info! I could not figure out why some of my windows would not drag and it was most certainly because I was not setting them to the value of their own rect. Once I did this, my problem was fixed.

avatar image
1

Answer by Shadyfella13 · Feb 25, 2011 at 01:44 AM

have a look at GUI.DragWindow. This should do the trick.

http://unity3d.com/support/documentation/ScriptReference/GUI.html

Comment
Add comment · Show 1 · Share
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
avatar image Flafla2 · May 26, 2011 at 09:52 PM 0
Share

Uhhhh... I did use it.....

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

No one has followed this question yet.

Related Questions

Activate function when GUI.Window is drag into area 0 Answers

Drag windows Not working 1 Answer

Popup window size problem 1 Answer

Move one GUI window when another is moved? 0 Answers

How to open a separate window 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