FPS ENGINE DOCUMENTATION
  • Welcome to FPS Engine!
  • BEFORE WE START
    • Early Considerations
    • List of Tutorials
    • List of Add-Ons & Compatible Packages
  • GETTING STARTED
    • 01. Basic set-up
    • 02. Roadmap
  • CONTENT
    • 03. Content
      • 03.1 CAMERA
        • MoveCamera
        • CameraFOVManager
      • 03.2 MOVEMENT
        • PlayerMovement
      • 03.3 PLAYER
        • PlayerStats
        • PlayerMultipliers
        • PLAYER STATES
          • PlayerStates
          • PlayerBaseState
          • PlayerStateFactory
        • WEAPON STATES
          • WeaponStates
          • WeaponBaseState
          • WeaponStateFactory
        • Player Debugging
      • 03.4 WEAPONS
        • Weapon_SO
        • WeaponIdentification
        • WeaponController
        • Bullet
        • ATTACHMENTS
          • Attachment.cs
            • Barrel.cs
            • Flashlight.cs
            • Magazine.cs
            • Scope.cs
            • Stock.cs
            • Laser.cs
            • Grip.cs
          • AttachmentIdentifier_SO.cs
      • 03.5 PICK UP SYSTEM
        • InteractManager
        • Interactable
        • Item_SO
        • Identifiable
        • Pickeable
          • WeaponPickeable
          • BulletsPickeable
          • AttachmentPickeable
      • 03.6 ENEMIES
        • IDamageable
        • EnemyHealth
        • TrainingTarget
        • CIrcularTargetEnemy
        • Turret
        • TurretProjectile
      • 03.7 EFFECTS
        • CameraEffects
        • CamShake
        • CrouchTilt
        • JumpMotion
        • ProceduralShot
        • ProceduralShot_SO
        • WeaponEffects
        • WeaponSway
      • 03.8 UI
        • CowsinsButton
        • Crosshair
        • CrosshairShape
        • Hitmarker
        • UIController
        • UIEvents
        • RebindUI
      • 03.8 EXTRA
        • Checkpoint
        • Coin
        • Compass
        • CompassElement
        • Destructible
        • Crate
        • ExplosiveBarrel
        • PowerUp
        • DamageMultiplier
        • HealMultiplierPowerUp
        • Healthpack
        • DoorInteractable
        • Experience
        • GetGameInformation
        • HurtTrigger
        • JumpPad
        • Lootbox
        • PauseMenu
        • PointCapture
        • Trigger
        • DraggableButtonInSceneView
        • UTILITIES
          • DestroyMe
          • IgnoreCollision
          • LookAt
          • CowsinsUtilities
      • 03.09 MANAGERS
        • CoinManager
        • ExperienceManager
        • GameSettingsManager
        • InputManager
        • SoundManager
        • PoolManager
  • HOW TO USE
    • Getting Started: First Steps
    • Importing FPS Engine into URP / HDRP
    • Add a Player Controller
    • Adding New Weapons
    • Saving & Loading Presets
    • Changing Keybindings
    • Creating New Pickeables
    • Controllable & Not Controllable Player
    • Adding New Surfaces ( Grounds )
    • Working with Attachments
    • Modify Weapon and Camera Effects
    • Adding Custom Key Rebinds
    • Add breakable (Destructible) objects
    • Custom Shot Weapons
    • Adding Enemies
  • FAQ
    • FAQ
  • SUPPORT
    • Support
Powered by GitBook
On this page
  • How to disable
  • How to add Custom Buttons to the Draggable Menu?
Export as PDF
  1. CONTENT
  2. 03. Content
  3. 03.8 EXTRA

DraggableButtonInSceneView

Introduced in 1.3

PreviousTriggerNextUTILITIES

Last updated 8 months ago

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

  2. Click on "Show Draggable Button in Scene View" to turn it off.

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:

#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

/// 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.

 /// 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.

 Debug.Log("Custom Button Clicked");