My problem is, when I attached my script to a game object, I want to make some calculation and add Edge Collider to this game object. Is there any event like "OnAttached" or something else?
Thanks for all your helps.
Thanks to Ruben I found the solution. RequireComponent is what I was looking for, but I actually needed an event like "OnAttached" and at last I found. It is "void Reset()".
The automated addition of the Edge Collider can be done by using [RequireComponent(typeof(EdgeCollider))]
Learn more here: https://docs.unity3d.com/ScriptReference/RequireComponent.html
Edit: OP says this wasn't helpful, refer to his comment below for more information:
You then can simply put all necessary calculations into the Start() functions, which get called, when a script is enabled.
https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With