Best Way to Simulate Unity's Inspector Transform Component in GameView UI

For debug purposes, for when my game is in fullscreen view, I was trying to recreate Unity’s Inspector Transform Component in GameView UI. Thus, I’d display Position with an X,Y,Z input field, Rotation with an X,Y,Z input field, and so on.

Currently, I have this working with input fields that take decimal values. The one issue I seem to be having is you cannot drag(slide) input fields to increase/decrease the value, like you can with Unity’s Transform component in the inspector. I’d like to achieve this, but I’m not sure about the best way to implement this. I’d like the user to be able to type the float values into the Input Field box, and also let them drag on the sides to change the Input Field box’s float value.

Does Unity’s UI already have something that can do this?

Hey there,

You should be able to extend Unity’s text field and add the drag event handler.

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class DragInput : InputField, IDragHandler
{
    public void OnDrag (PointerEventData eventData)
    {
        //Your logic here (this logic might suck but you get the point) :)
        inputValue += eventData.delta;
    }
}

This will take some tweeting but it should be able to give you the results your want.

Regards,

@BMayne , thanks for the info. That did it. It’d be nice if in Unity’s own tutorials they mentioned the Interfaces they have.

1 Like

They have some information about the event interfaces here Redirecting to latest version of com.unity.ugui