public void DrawBehaviour()
    {
        RnMUI_IconSlot mSlot = target as RnMUI_IconSlot;

        serializedObject.Update();

        if (NGUIEditorTools.DrawHeader("Behaviour"))
        {
            NGUIEditorTools.BeginContents();
            EditorGUIUtility.labelWidth = 150f;
            GUILayout.BeginVertical();

            // Hover Effect
            NGUIEditorTools.DrawProperty("Hover Effect Type", serializedObject, "hoverEffectType");

            if (mSlot.hoverEffectType == RnMUI_IconSlot.HoverEffectType.Sprite)
            {
                NGUIEditorTools.DrawProperty("Hover Sprite", serializedObject, "hoverEffectSprite");
            }
            else if (mSlot.hoverEffectType == RnMUI_IconSlot.HoverEffectType.Color)
            {
                NGUIEditorTools.DrawProperty("Hover Color", serializedObject, "hoverEffectColor");
            }

            // Hover effect speed value
            if (mSlot.hoverEffectType != RnMUI_IconSlot.HoverEffectType.None)
            {
                NGUIEditorTools.DrawProperty("Hover Tween Duration", serializedObject, "hoverEffectSpeed");
            }

            GUILayout.Space(10f);
            GUILayout.EndVertical();

            // Press Effect
            NGUIEditorTools.DrawProperty("Press Effect Type", serializedObject, "pressEffectType");

            if (mSlot.pressEffectType == RnMUI_IconSlot.PressEffectType.Sprite)
            {
                NGUIEditorTools.DrawProperty("Press Sprite", serializedObject, "pressEffectSprite");
            }
            else if (mSlot.pressEffectType == RnMUI_IconSlot.PressEffectType.Color)
            {
                NGUIEditorTools.DrawProperty("Press Color", serializedObject, "pressEffectColor");
            }

            // Press effect speed value
            if (mSlot.pressEffectType != RnMUI_IconSlot.PressEffectType.None)
            {
                NGUIEditorTools.DrawProperty("Press Tween Duration", serializedObject, "pressEffectSpeed");
                NGUIEditorTools.DrawProperty("Press Tween Insta Out", serializedObject, "pressEffectInstaOut");
            }

            NGUIEditorTools.EndContents();
        }

        serializedObject.ApplyModifiedProperties();
    }
    /// <summary>
    /// Performs a slot swap.
    /// </summary>
    /// <param name="targetObject">Target slot.</param>
    public virtual bool PerformSlotSwap(Object targetObject)
    {
        // Get the source slot
        RnMUI_IconSlot targetSlot = (targetObject as RnMUI_IconSlot);

        // Get the target slot icon
        Texture targetIcon = targetSlot.GetIcon();

        // Assign the target slot with this one
        bool assign1 = targetSlot.Assign(this);

        // Assign this slot by the target slot icon
        bool assign2 = this.Assign(targetIcon);

        // Return the status
        return(assign1 && assign2);
    }
    /// <summary>
    /// Assign the specified slot by source object.
    /// </summary>
    /// <param name="source">Source.</param>
    public virtual bool Assign(Object source)
    {
        if (source is Texture)
        {
            return(this.Assign(source as Texture));
        }
        else if (source is RnMUI_IconSlot)
        {
            RnMUI_IconSlot sourceSlot = source as RnMUI_IconSlot;

            if (sourceSlot != null)
            {
                return(this.Assign(sourceSlot.GetIcon()));
            }
        }

        return(false);
    }
    public void DrawDragAndDrop()
    {
        RnMUI_IconSlot mSlot = target as RnMUI_IconSlot;

        serializedObject.Update();

        NGUIEditorTools.DrawProperty("Drag and Drop", serializedObject, "dragAndDropEnabled");

        // When drag and drop is enabled
        if (mSlot.dragAndDropEnabled)
        {
            NGUIEditorTools.DrawProperty("Allow throw away", serializedObject, "AllowThrowAway");
            NGUIEditorTools.DrawProperty("Is Static", serializedObject, "IsStatic");

            if (mSlot.IsStatic)
            {
                EditorGUILayout.HelpBox("Static slots are intended to be used for spell books and such because they will not be unassigned when drag is strated.", MessageType.Warning);
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
    /// <summary>
    /// Raises the drag drop release event.
    /// </summary>
    /// <param name="surface">Surface.</param>
    protected virtual void OnDragDropRelease(GameObject surface)
    {
        // Destroy the temporary icon
        if (this.mTemporaryDraggingPanel != null)
        {
            NGUITools.Destroy(this.mTemporaryDraggingPanel);
        }
        else if (this.mDraggedObject != null)
        {
            NGUITools.Destroy(this.mDraggedObject);
        }

        // Check if we have no surface
        if (surface == null)
        {
            // No surface found
            // Try to throw away the slot content
            this.OnThrowAway();
            return;
        }

        // Try getting a target slot
        RnMUI_IconSlot targetSlot = surface.GetComponent <RnMUI_IconSlot>();

        // Check if we have a target slot
        if (targetSlot == null)
        {
            // No target slot
            // Check if we handle custom surface
            if (!this.HandleCustomSurface(surface))
            {
                // Try to throw away the slot content
                this.OnThrowAway();
            }
            return;
        }

        // Check if the target slot has drag and drop enabled
        if (targetSlot.dragAndDropEnabled)
        {
            // Normal empty slot assignment
            if (!targetSlot.IsAssigned())
            {
                // Assign the target slot with the info from this one
                if (targetSlot.Assign(this) && !this.IsStatic)
                {
                    this.Unassign();
                }
            }
            // The target slot is assigned
            else
            {
                // If the target slot is not static
                // and this slot is not static
                if (!targetSlot.IsStatic && !this.IsStatic)
                {
                    // Check if we can swap
                    if (this.CanSwapWith(targetSlot) && targetSlot.CanSwapWith(this))
                    {
                        // Swap the slots
                        this.PerformSlotSwap(targetSlot);
                    }
                }
                // If the target slot is not static
                // and this slot is a static one
                else if (!targetSlot.IsStatic && this.IsStatic)
                {
                    targetSlot.Assign(this);
                }
            }
        }
    }