Farrukh Sajjad
Farrukh Sajjad

Reputation: 353

Only want to have positive value for Vector3 - Unity

I am creating a game which involves scaling the game object and I only want it to have positive values for its Vector3. enter image description here

How can I do that?

Upvotes: 1

Views: 1081

Answers (1)

Milan Egon Votrubec
Milan Egon Votrubec

Reputation: 4049

You can listen for the OnValidate message like this:

    private void OnValidate ( )
    {
        if ( ScaleFactor.x < 0 ) ScaleFactor.x = 0;
        if ( ScaleFactor.y < 0 ) ScaleFactor.y = 0;
        if ( ScaleFactor.z < 0 ) ScaleFactor.z = 0;
    }

Here's the official documentation.

Upvotes: 1

Related Questions