Search Unity

[Bug? or Help needed] with Unity 4.6 I have a Problem with Objectfields and a custom GUISkin

Discussion in 'Immediate Mode GUI (IMGUI)' started by Deleted User, Dec 3, 2014.

  1. Deleted User

    Deleted User

    Guest

    Hello, I'm developing an editor extension which makes use of a custom GUISkin and it worked everything well with Unity 4.5, until I started to use Unity 4.6...
    I wanted to wait for the official 4.6 release to port my extension to it, so now that I tested it I don't get around the following problem:

    When I display an Objectfield for texture selection (Objectfield stands under the EditorGUI Class not the normal GUI class), it asks me for an "ObjectFieldThumbOverlay" and "ObjectFieldThumbOverlay2" definition in the skin that I use. Now I have two questions:

    Why does it need at all a ObjectFieldThumbOverlay in 4.6, when the Objectfield should be drawn from the native GUI Skin the Editor already has?

    And if we really need to specify now a ObjectFieldThumbOverlay, where do we do that exactly?

    I know how to do customstyles (indeed I use some in my own Skin and my extension, set everything up etc. and like I said it worked until 4.5), I can't find any way how to define it. The GUISkin Inspector in Unity only has options for Buttons, Textfields, Labels, Window etc. but none for Objectfields, and I guess defining the ObjectFieldThumbOverlay as a customstyle is not the solution, as the customstyles are accessed by an Array.. (like.: GUI.Skin.customStyles[2]). I even don't know how the ObjectFieldThumbOverlay should look like, any example available??

    To see if I just did something wrong in my own code I quickly made this example as a test:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using System.Collections;
    4.  
    5. namespace Valentactive.NewCompo
    6. {
    7.     public class NewCompo : EditorWindow
    8.     {
    9.  
    10.         // Data:
    11.         private Texture TextureToSet;
    12.         private static GUISkin TagCompoSkin = null;
    13.  
    14.         // Adds menu entry named "NewCompo" to the Window menu
    15.         // and initializes the variables:
    16.         [MenuItem("Window/NewCompo")]
    17.         static void Init()
    18.         {
    19.             NewCompo window = (NewCompo)EditorWindow.GetWindow(typeof(NewCompo));
    20.             window.title = "Window1";
    21.             if (TagCompoSkin == null)
    22.             {
    23.                 TagCompoSkin = (GUISkin)(Resources.LoadAssetAtPath("Assets/Editor/TagCompo/TagCompoSkin.guiskin", typeof(GUISkin)));
    24.             }
    25.        
    26.         }
    27.  
    28.         void OnGUI()
    29.         {
    30.             GUI.skin = TagCompoSkin;  //Sets the skin to the "TagCompoSkin"
    31.             EditorGUILayout.BeginVertical();
    32.             EditorGUILayout.LabelField("Bug Example:");
    33.             TextureToSet = (Texture)EditorGUILayout.ObjectField("Texture:", TextureToSet, typeof(Texture), false);  //Sets the private TextureToSet with the Texture that we chose on this Objectfield
    34.             EditorGUILayout.EndVertical();
    35.         }
    36.     }
    37. }
    38.  
    Or is it just a new bug?
    Did anyone else face similar problems?
     

    Attached Files:

    Last edited by a moderator: Dec 3, 2014