create custom mask unity3D

Asked

Viewed 175 times

1

How to create a date mask on the Unity 3D platform, so that when I type, it automatically places the characters "/"?

Example: 00/00/0000

  • unity3D, supports Javascript?

  • @Marconciliosouza In Unit you can program in Javascript or C#

  • @Evandro What you’ve done with your project?

  • 1

    In general you will have to make a code that checks the text that was typed and add the bars. Since you did not give more details I would say that the implementation will be done in the onGui method of the class that will control whatever you are doing. But it might not be any of those things... anyway

  • I’m using c# I can make a mixture with javascript?

1 answer

2


Evandro don’t know what you call a Function using unity3D, but the Function below does what you need.

function mdata(v) {
  v = v.replace(/\D/g, "");                    //Remove tudo o que não é dígito
  v = v.replace(/(\d{2})(\d)/, "$1/$2");
  v = v.replace(/(\d{2})(\d)/, "$1/$2");

  v = v.replace(/(\d{2})(\d{2})$/, "$1$2");
  return v;
}
  • 1

    That’s the line right there, as soon as he tells us what his implementation is, we’ll know. At the moment I would guess that he will use this in the function Ongui() in some active controller class.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.