Search Unity

Snapshot release of ColdGUI 0.1 for Unity 3.1

Discussion in 'Immediate Mode GUI (IMGUI)' started by soenberg, Nov 12, 2010.

  1. LeftyRuhk

    LeftyRuhk

    Joined:
    Feb 20, 2011
    Posts:
    1
    Hi, great tool! I've been able to use it to quickly add buttons and hook up click events etc. I'm using unity 3.2.0f4 on the Mac. I have a GUIButton that I want to change its texture depending on where it is clicked and I just had a couple questions:

    1) How can I access the skin or texture of a GUIButton? I tried the following code but got the error "error CS0122: `DK.Apex.ColdGUI.AGUIComponent.skin' is inaccessible due to its protection level":

    2) I built a root and added a single GUIButton to it. Now I am unable to change the position of the button within the editor by dragging it, though I can re-size it. Manually changing the X and Y in the inspector does work to position the button. In addition, when I run the game from within unity I get spammed with thousands of the following error, though everything seems to be working fine (the button shows up, responds to clicks, etc.)

    Any ideas?

    Thanks,
    David
     
  2. KlingOne

    KlingOne

    Joined:
    Dec 1, 2010
    Posts:
    9
    Hi,
    I've also came across another problem. If you have GuiGroup inside a GuiGroup and inside of the inner GuiGroup are elements that are larger than the GuiGroup the scrollbars appear in the wrong position. It seems like they are alligned to the first GuiGroup rather than to the one the large items are really in.
    Hope it came across what I mean.
     
  3. wlad_s

    wlad_s

    Joined:
    Feb 18, 2011
    Posts:
    148
    Hi,

    I know that for some this would be a stupid question but I can't seem to find any tutorial or a reference regarding the connecting the GUI buttons with actual in-game events.

    How do I do this? I've programmed a character, running, sliding, jumping, everything works fine just as I want it to. I've learned all that through reference and tutorials. All I've managed to find is this in the script reference:

    But this doesn't help me to understand how to reference ColdGUI Buttons that I've already made :(
     
  4. louis

    louis

    Joined:
    Jan 23, 2006
    Posts:
    62
    @uberwleiss
    I'm afraid I'm not familiar with ColdGUI, but the code you posted might give you some ideas.
    I presume you've exported your character from your modelling application and that you've named
    all the animations. (I'm assuming here that one animation is called Walk and one animation is called Run)
    To fire the animations in your character from the buttons drawn with the GUI code you've posted
    you could do this:
    In Unity under the Assets menu choose Create -> Javascript.
    Paste the code below into your new script and drop it onto your character.
    Hit the Play button (N.B. make sure the animation names match the animation names you
    gave your character in the modelling app ie. Walk, Run etc

    Code (csharp):
    1.  
    2. // Draw 2 buttons with text on them
    3. //When clicked the buttons play the named animations embedded in the GameObject that the script is attached to
    4. // Prints a message confirming that the buttons got clicked.
    5.  
    6.  
    7. function OnGUI()
    8. {
    9. if (GUI.Button(Rect(10,10,50,30),"Run"))
    10. {
    11. this.animation.Play("Run");
    12. Debug.Log("Clicked the button called Run and triggered the animation named Run");
    13. }
    14.  
    15. if (GUI.Button(Rect(10,70,50,30),"Walk"))
    16. {
    17. this.animation.Play("Walk");
    18. Debug.Log("Clicked the button called Walk and triggered the animation named Walk");
    19. }
    20. }
    21.  
     
    Last edited: Feb 24, 2011
  5. soenberg

    soenberg

    Joined:
    Sep 20, 2010
    Posts:
    18
    @uberwleiss: To add event handling to buttons in ColdGUI, you need to assign a delegate function to the ButtonDelegate in the GUIButton. For example:
    Code (csharp):
    1. void Start()
    2. {
    3.     GUIButton button = GetComponent<GUIButton>();
    4.     button.ButtonDelegate += new Delegates.VoidDelegate(RunAnimation);
    5. }
    6.  
    7. void RunAnimation(IGUIComponent sender)
    8. {
    9.     animation.Play("AnimationName");
    10. }
    This should be added to the gameobject containing the GUIButton you wish to use.

    Regards,
    Tore Sønberg Madsen
    Apex Virtual Entertainment
     
  6. soenberg

    soenberg

    Joined:
    Sep 20, 2010
    Posts:
    18
    @LeftyRuhk: Changing the texture of a button is not supported yet as I do not expose the GUIContent property of the GUI.Button call. I will update this in a later version. The Skin property is to be used in the editor only.

    @KlingOne @ LeftyRuhk: I will take a look at the error you are getting, see if I can reproduce them and find a fix.

    Regards,
    Tore Sønberg Madsen
    Apex Virtual Entertainment
     
  7. KlingOne

    KlingOne

    Joined:
    Dec 1, 2010
    Posts:
    9
  8. Esila

    Esila

    Joined:
    Mar 22, 2009
    Posts:
    105
    coldgui support draggable window???
     
  9. JilJill

    JilJill

    Joined:
    Nov 11, 2009
    Posts:
    132
    should this work for unity 2.6. i get the follwing error when i try to run in uniy 2.6:
    Assets/ColdGUI/Editor/GUIEditorUtilities.cs(301,50): error CS0117: `UnityEngine.Vector2' does not contain a definition for `one'

    It points me to the following line:

    Vector3 vectorSize = Vector2.one * size * 2;

    i read that Vector2 does not include one in it so i changed it to Vector3, but that did not do anything either. could you please help this looks very good.
     
  10. Thetal

    Thetal

    Joined:
    Nov 5, 2010
    Posts:
    92
    I would back jimjim request - 2.6.1 compatibility would be nice to have.

    And thank you for a great tool!
     
  11. calvintang

    calvintang

    Joined:
    Jan 13, 2012
    Posts:
    1
    Hello, newbie here.
    I wonder is it possible to force the coldgui editor to work at a lower resolution?

    Here is a better explaination
    At the GUIRoot (Script) I had placed the width and height at 1920x1080, but my monitor only supports up to 1680x1080.
    I place it at that resolution so that it would be able to scale down nicely when I make my demo application. So the question is that how do I make everything smaller (when it is still at the higher resolution?)
    Thanks in advance!
     
  12. kingcharizard

    kingcharizard

    Joined:
    Jun 30, 2011
    Posts:
    1,137
    Why is their no examples? I dont wanna download this if I dont know exactly if i need it or what it is..
     
  13. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Alright, this is very cool. As soon as my disc is done defragmenting I will take a look at this for sure. How much does it add onto your project size, though...

    Screenshots, or even a web player would be very helpful in determining the worth of the plugin.
     
  14. CapsE

    CapsE

    Joined:
    Apr 5, 2012
    Posts:
    1
    Hi I have a little bug to report. I got a GUIImage that is placed half way out of the screen and I want to rotate it so the former not visible part comes into the screen. The problem is that the image is cut at the exact same place no matter in which rotation it is. (If I move it to the center of the screen erverything works fine)



    On the left you can see the rotated picture in my game. On the right you can see the original picture I use. (As said above the image only is cut if it reaches the upper border of the screen)

    PS: Is there a way how I can avoid these problems?