Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How would the logic behind this 'window' concept work?

Discussion in '2D' started by Skyber21, Jul 5, 2015.

  1. Skyber21

    Skyber21

    Joined:
    Jul 5, 2015
    Posts:
    3
    Okay, so we're working on a game in Unity, and we want to replicate the behavior of windows in an operating system. Specifically opening a window, having the ability to move the windows around, and being able to close them as well. In theory, it sounds simple:

    • When a button somewhere else in the scene is pushed, the corresponding window for that button should pop up.

    • Each 'window' is made up of sprites and buttons. When a specific sprite is clicked on and being dragged, we want the the other sprites and buttons that make up that window to move also.

    • When a close button in the window is pushed, the window should disappear.

    • We need the ability to have multiple windows open at any given time.
    It sounds possible, we're just not quite sure on how to do it, exactly.

    Cheers,

    Skyber21
     
  2. Skyber21

    Skyber21

    Joined:
    Jul 5, 2015
    Posts:
    3
    *bump*
     
  3. truecrisis

    truecrisis

    Joined:
    Feb 17, 2015
    Posts:
    8
    I'm a noob, so I really shouldn't be writing here, but I think you would make everything a child of an object.

    For example, make an empty game object, and then drag some sprites into the editor so that they are children of that.
    If you update the XY of the parent, all the others follow it around. So there is your movement.

    I'm sure the same must apply to visibility and such. Tell one of the child buttons to change the visibility setting on the parent to get the window to disappear.

    For multiple windows, just instantiate a new parent.

    Sorry in advance if I really am out of my place posting this.
     
  4. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,732
  5. Skyber21

    Skyber21

    Joined:
    Jul 5, 2015
    Posts:
    3
    Thank you all for your suggestions. Once our programmer comes back from his vacation, we'll try out these solutions. If anybody else has a solution that they think we should try out, please don't hesitate to make a reply.