Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

on changed callback for every number input field

Discussion in 'Immediate Mode GUI (IMGUI)' started by Gerold_Meisinger, Jan 24, 2018.

  1. Gerold_Meisinger

    Gerold_Meisinger

    Joined:
    Sep 8, 2015
    Posts:
    93
    Hi! Does anyone know how to intercept every change to a number input field (for example position x in transform), perform some calculations on the entered string and write a changed value to the property. For example if someone inputs a german comma-separator "123,456" it should get interpreted as "123.456". I only need this for Transform, so if the solution is only applicable for Transforms that's fine, but a general solution for all float input fields would be nice.

    My current solution is to completely rewrite the transform inspector based on this wiki script and replace each PropertyField by 3 text input labels, check for changes and parse to floats. But then again this won't work well with the Advanced Inspector plugin, which already does some rewriting.

    I am aware of PropertyDrawer but so far I was only able to rewrite typeof( float ), not Vector3 or Transform.
     
    Last edited: Jan 24, 2018