Unity Community


Results 1 to 3 of 3

  1. Location
    Melbourne, Australia
    Posts
    30

    Using GUIStyle and C#

    I'm just getting started with Unity GUI, and am having trouble getting GUIstyle to work with C#. To start with I'd like to expose GUI style varibles to the inspector, like in the documentation with js:

    Making a public variable GUIStyle
    http://unity3d.com/support/documenta...omization.html

    I've tried to convert the example to C# but no GUI style varibles are exposed to the inspector (see code below). All I get is a field for a Game Object of type GUIstyle.

    Code:  
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class GUIStyle : MonoBehaviour {
    5.  
    6.     public GUIStyle myGUIStyle;
    7.        
    8.     void OnGUI () {
    9. //      GUI.Button (new Rect (10,10,150,20), "I am a Custom Button", myGUIStyle); // this wont compile
    10.     }
    11. }

    Any ideas?

  2. sc3 sc3 is offline

    Posts
    97
    Try changing your script/class name to something other than GUIStyle.


  3. Location
    Melbourne, Australia
    Posts
    30
    Ah, thanks very much. That was the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •