Search Unity

GUI, material help

Discussion in 'Immediate Mode GUI (IMGUI)' started by mike777, Oct 16, 2010.

  1. mike777

    mike777

    Joined:
    Oct 11, 2010
    Posts:
    42
    Hello
    I need help with GUI and material.
    What I need is a button on the screen that says "material", when you press it a GUI box appears, and in it is a list of materials, like metal, wood... when you press one of them another GUI box appears and list what kind of metal, or wood, and so on. Then I need to be able to drag one of the materials onto a object.

    Please help this is important.
    Thanks
     
    Last edited: Oct 16, 2010
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Is a selection grid what you need here? Perhaps you can give some more detail about the dragging process. Do you need to drag a small representative of the material from the GUI to the scene or to another GUI element or... ?
     
  3. mike777

    mike777

    Joined:
    Oct 11, 2010
    Posts:
    42
    I need to be able to drag a material from the GUI box onto an object, and the object switches material from the frist one to the the new one.
    The GUI box is organized in rows and columns. The first GUI box that appaers has the names of broad materials, like wood, metal... When you press one of them their own GUI box appears, like when you press wood and GUI box appears that only says different types of wood. Then when you find the material you want you drag it onto an object. The objects material switches to the new one.

    Thanks
     
    Last edited: Oct 18, 2010
  4. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    I've attached a script that implements a grid of draggable "swatches" of materials along with a scene that demonstrates it. It's quite basic but should be a good starting point for what you are doing.
     

    Attached Files:

    dl_studios likes this.
  5. mike777

    mike777

    Joined:
    Oct 11, 2010
    Posts:
    42
    Thanks alot.
    That helped a lot.
    Also how do you make it so you can also drag models onto the sence from another GUI box.

    Also when I switch the material using the file you gave me can I switch the materials for any model, like a complex model, it does not switch the the material but to a solid color, like brown, purple...




    Thanks
     
    Last edited: Oct 21, 2010
  6. mike777

    mike777

    Joined:
    Oct 11, 2010
    Posts:
    42
    Also when I switch the colors you can see the first color mixed with the second instead of switching entirely to the sconcd
     
    Last edited: Oct 21, 2010
  7. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    You could put a grid of swatches into a scrollview to allow more than one set onscreen at a time.

    As for the other problem, the code I posted replaces the current texture of the material with a new texture. I'm not sure exactly what is going wrong when you try to use it - can you give some more detail and perhaps post a screenshot that shows what is happening?
     
  8. mike777

    mike777

    Joined:
    Oct 11, 2010
    Posts:
    42
    Thanks
    the first pic shows 2 cubes at the start.
    I dragged the blue/white material onto both of them.
    In the second pic it shows both cube where given the same material.
    the white cube looks fine, but the red one still has its first material mixed with the blue/white one.
    Thanks for your help

    Also how do I make a drag and drop for models.
     

    Attached Files:

    Last edited: Oct 28, 2010