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. Dismiss Notice

GuiTextures

Discussion in 'Scripting' started by Findo, May 9, 2014.

  1. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    How do I load GUITextures? Can I make them in paint.Net? :D
     
  2. MysteriX

    MysteriX

    Joined:
    Apr 8, 2014
    Posts:
    54
    You could create a public variable and assign the Texture at the inspector.
    You can create whereever you want. Would be good if the program can handle and save transparent areas. I also work with paint.Net. Its free and easy to use.

    Example:
    Add this line in your class but not in a method. Then if you have assigned the script to an object, you can assign your texture in the inspector.
    Code (csharp):
    1.  
    2. public GUITexture _guiTexture;
    3.  
     
  3. SmokyZebra

    SmokyZebra

    Joined:
    Mar 13, 2014
    Posts:
    139
    You don't even need to script to have a GUITexture : create it, click on it in the hierarchy, drag and drop your texture in the appropriate slot in the Inspector. Adjust size to fit your original file. And last, adjust position on screen. That's it.
     
  4. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    how do I create it? :D
     
  5. Erisat

    Erisat

    Joined:
    Jan 31, 2013
    Posts:
    88
    Findo, i use paint.net to make my icons on gui for items and such. what i did in paint.net was make a 64x64 image, clear it so that background would be transparent(the checkerboard pattern in paint.net represents transparency), throw something on it like a crappy helmet icon (im no artist), and save as .png.
    then i create a public reference in my script for the texture

    public Texture icontex;

    then i import the image i made in paint.net, and drag&drop the image to the inspector variable for icontex in my scene.

    (i actually use an array of textures, for instance to display 22 different inv slots, but thats a dif story.)
     
  6. laurelhach

    laurelhach

    Joined:
    Dec 1, 2013
    Posts:
    229
  7. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368

    Ok, Cool, I have an inventory too, (only has 15 slots though D: ) and,,, um... how do I import an image? :D
     
  8. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,605
    Start here: http://unity3d.com/learn

    Read the docs.
     
  9. Findo

    Findo

    Joined:
    Mar 11, 2014
    Posts:
    368
    I'd rather google it.