示例#1
0
    /// <summary>
    /// Draw a button + object selection combo filtering specified types.
    /// </summary>

    static public void Draw <T> (string buttonName, T obj, OnSelectionCallback cb, bool editButton, params GUILayoutOption[] options) where T : Object
    {
        GUILayout.BeginHorizontal();
        bool show = UGUIEditorTools.DrawPrefixButton(buttonName);
        T    o    = EditorGUILayout.ObjectField(obj, typeof(T), false, options) as T;

        if (editButton && o != null && o is MonoBehaviour)
        {
            Component mb = o as Component;
            if (Selection.activeObject != mb.gameObject && GUILayout.Button("Edit", GUILayout.Width(40f)))
            {
                Selection.activeObject = mb.gameObject;
            }
        }
        else if (o != null && GUILayout.Button("X", GUILayout.Width(20f)))
        {
            o = null;
        }
        GUILayout.EndHorizontal();
        if (show)
        {
            Show <T>(cb);
        }
        else
        {
            cb(o);
        }
    }
示例#2
0
    /// <summary>
    /// Draw the atlas and sprite selection fields.
    /// </summary>

    protected virtual bool ShouldDrawProperties()
    {
        GUILayout.BeginHorizontal();
        if (UGUIEditorTools.DrawPrefixButton("Atlas"))
        {
            ComponentSelector.Show <UGUIAtlas>(OnSelectAtlas);
        }
        SerializedProperty atlas = UGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));

        if (GUILayout.Button("Edit", GUILayout.Width(40f)))
        {
            if (atlas != null)
            {
                UGUIAtlas atl = atlas.objectReferenceValue as UGUIAtlas;
                UGUISettings.atlas = atl;
                UGUIEditorTools.Select(atl.gameObject);
            }
        }
        GUILayout.EndHorizontal();

        UGUISprite uguiSprite = target as UGUISprite;
        string     spriteName = uguiSprite.sprite == null ? "" : uguiSprite.sprite.name;

        UGUIEditorTools.DrawAdvancedSpriteField(atlas.objectReferenceValue as UGUIAtlas, spriteName, SelectSprite, true);
        return(true);
    }