Question by
Grimbyte · Nov 16, 2016 at 07:54 PM ·
monobehaviourrandom.range
Is there a way to use Random.Range without inheriting from Monobehaviour?
I have a class that does not inherit from Monobehaviour, and I want to use Random.Range. Is there any way I could do this?
Comment
Best Answer
Answer by elenzil · Nov 16, 2016 at 09:25 PM
no problem: just call it as UnityEngine.Random.Range()
instead of Random.Range()
.
Yup. Random.Range() is a static method in UnityEngine.Random class as can be seen from the way it's called. Doesn't matter which class you call it from.
Your answer
![](https://koobas.hobune.stream/wayback/20220612100821im_/https://answers.unity.com/themes/thub/images/avi.jpg)