# DraggableButtonInSceneView

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FJZpBs9fTUDxC61QUjO5t%2Fimage.png?alt=media&#x26;token=ad182ced-04fd-4640-83af-45b1d522940b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2F92aUdrzHbAw79UC0Lmso%2Fimage.png?alt=media&#x26;token=d085b7c4-5b39-40df-9d56-293a0dcab99a" alt=""><figcaption></figcaption></figure>

Creates a Button that can be dragged. On clicked, it opens a menu with different options that will help you do more in less time with FPS Engine

### How to disable

Disabling **DraggableButtonInSceneView** is very simple,

1. Go to the top toolbar and Click on Cowsins/FPS Engine Start Up

   <figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FVFfDwshCS4HZCTybpqQp%2Fimage.png?alt=media&#x26;token=d1175d99-991c-49c9-bac0-13b472c09419" alt=""><figcaption></figcaption></figure>
2. Click on "Show Draggable Button in Scene View" to turn it off.

<figure><img src="https://2716441118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkdlNMXOYYmupb4VpBGHT%2Fuploads%2FDiTsSK7kZcoUmOtCoCrt%2Fimage.png?alt=media&#x26;token=6590274f-c053-4795-b72c-06830ac0096f" alt="" width="275"><figcaption></figcaption></figure>

### How to add Custom Buttons to the Draggable Menu?

In ExternalButtonRegister.cs you can find all the template code you need.

Take a look at the following code:&#x20;

```csharp
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;

namespace cowsins
{
    [InitializeOnLoad]
    public static class ExternalButtonRegister
    {
        static ExternalButtonRegister()
        {
            DraggableButtonInSceneView.OnAddExternalButtons += AddCustomButtons;
        }

        private static void AddCustomButtons(Rect menuRect)
        {
            float itemWidth = menuRect.width / 3;
            float itemHeight = menuRect.height;

            /// OVERRIDE BUTTON COUNT ( NECESSARY ) 
            DraggableButtonInSceneView.buttonCount = 5;

            /// ADD 5TH BUTTON
            Texture2D customButtonImage = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/CustomButton.png");
            // Add custom button
            if (GUI.Button(new Rect(DraggableButtonInSceneView.GetButtonPosition(menuRect, 4), menuRect.y, itemWidth, itemHeight), customButtonImage))
            {
                Debug.Log("Custom Button Clicked");
            }
        }
    }
}
#endif
```

> ```csharp
> /// OVERRIDE BUTTON COUNT ( NECESSARY ) 
> DraggableButtonInSceneView.buttonCount = 5;
> ```
>
> As you can see, the button Count is set to 5. The original button count for the Draggable Menu is 4, since there are 4 buttons. As we are adding a new button, we must update the button count to 5.

> ```csharp
>  /// ADD 5TH BUTTON
>  Texture2D customButtonImage = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/CustomButton.png");
>  // Add custom button
>  if (GUI.Button(new Rect(DraggableButtonInSceneView.GetButtonPosition(menuRect, 5), menuRect.y, itemWidth, itemHeight), customButtonImage))
>  {
>     Debug.Log("Custom Button Clicked");
>  }
> ```
>
> This is the code necessary to add a new Button.
>
> First we gather the Texture or Image we want to display on the button. Change **"Assets/CustomButton.png"** with your own path.
>
> \
> Inside the creation of the Rect, make sure 5 corresponds to the current button index being added, in this case, it is correct, as we are making a 5th button. **GetButtonPosition(menuRect, 5)**\
> \
> Inside the if statement, you can add all the code you need to perform on clicking the button. Right now, it only displays a message.
>
> ```csharp
>  Debug.Log("Custom Button Clicked");
> ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cowsinss-organization.gitbook.io/fps-engine-documentation/content/03.-content/03.8-extra/draggablebuttoninsceneview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
