11/* Part of KSPPluginFramework
22Version 1.2
33
4- Forum Thread:http ://forum.kerbalspaceprogram.com/threads/66503-KSP-Plugin-Framework
4+ Forum Thread:https ://forum.kerbalspaceprogram.com/topic/60381-ksp-plugin-framework-plugin-examples-and-structure/
55Author: TriggerAu, 2014
66License: The MIT License (MIT)
77*/
@@ -57,8 +57,8 @@ public abstract class MonoBehaviourExtended : MonoBehaviour
5757 //}
5858 static MonoBehaviourExtended ( )
5959 {
60+ //Must do this in awake now
6061 //UnityEngine.Random.seed = (int)(DateTime.Now - DateTime.Now.Date).TotalSeconds;
61- UnityEngine . Random . InitState ( ( int ) ( DateTime . Now - DateTime . Now . Date ) . TotalSeconds ) ;
6262 }
6363 #endregion
6464
@@ -256,16 +256,29 @@ private void RepeatingWorkerWrapper()
256256 #endregion
257257
258258 #region Standard Monobehaviour definitions-for overriding
259- //See this for info on order of execuction
260- // http ://docs.unity3d.com/Documentation /Manual/ExecutionOrder.html
259+ //See this for info on order of execution
260+ // https ://docs.unity3d.com/Manual/ExecutionOrder.html
261261
262262 /// <summary>
263263 /// Unity Help: Awake is called when the script instance is being loaded.
264264 ///
265265 /// Trigger: Override this for initialization Code - this is before the Start Event
266- /// See this for info on order of execuction: http ://docs.unity3d.com/Documentation /Manual/ExecutionOrder.html
266+ /// See this for info on order of execution: https ://docs.unity3d.com/Manual/ExecutionOrder.html
267267 /// </summary>
268- internal virtual void Awake ( )
268+ private void Awake ( )
269+ {
270+ if ( ! randomInitialized )
271+ {
272+ UnityEngine . Random . InitState ( ( int ) ( DateTime . Now - DateTime . Now . Date ) . TotalMilliseconds ) ;
273+ randomInitialized = true ;
274+ }
275+
276+ OnAwake ( ) ;
277+ }
278+
279+ private static bool randomInitialized = false ;
280+
281+ internal virtual void OnAwake ( )
269282 {
270283 LogFormatted_DebugOnly ( "New MBExtended Awakened" ) ;
271284 }
@@ -274,7 +287,7 @@ internal virtual void Awake()
274287 /// Unity: Start is called on the frame when a script is enabled just before any of the Update methods is called the first time.
275288 ///
276289 /// Trigger: This is the last thing that happens before the scene starts doing stuff
277- /// See this for info on order of execuction: http ://docs.unity3d.com/Documentation /Manual/ExecutionOrder.html
290+ /// See this for info on order of execution: https ://docs.unity3d.com/Manual/ExecutionOrder.html
278291 /// </summary>
279292 internal virtual void Start ( )
280293 {
@@ -285,7 +298,7 @@ internal virtual void Start()
285298 /// Unity: This function is called every fixed framerate frame, if the MonoBehaviour is enabled.
286299 ///
287300 /// Trigger: This Update is called at a fixed rate and usually where you do all your physics stuff for consistent results
288- /// See this for info on order of execuction: http ://docs.unity3d.com/Documentation /Manual/ExecutionOrder.html
301+ /// See this for info on order of execution: https ://docs.unity3d.com/Manual/ExecutionOrder.html
289302 /// </summary>
290303 internal virtual void FixedUpdate ( )
291304 { }
@@ -294,7 +307,7 @@ internal virtual void FixedUpdate()
294307 /// Unity: LateUpdate is called every frame, if the MonoBehaviour is enabled.
295308 ///
296309 /// Trigger: This Update is called just before the rendering, and where you can adjust any graphical values/positions based on what has been updated in the physics, etc
297- /// See this for info on order of execuction: http ://docs.unity3d.com/Documentation /Manual/ExecutionOrder.html
310+ /// See this for info on order of execution: https ://docs.unity3d.com/Manual/ExecutionOrder.html
298311 /// </summary>
299312 internal virtual void LateUpdate ( )
300313 { }
@@ -308,7 +321,7 @@ internal virtual void LateUpdate()
308321 ///
309322 /// NOTE: The class must be attached to a camera object to have this get called - obj = MapView.MapCamera.gameObject.AddComponent<MBExtended>();
310323 ///
311- /// See this for info on order of execuction: http ://docs.unity3d.com/Documentation /Manual/ExecutionOrder.html
324+ /// See this for info on order of execution: https ://docs.unity3d.com/Manual/ExecutionOrder.html
312325 /// </summary>
313326 internal virtual void OnPreCull ( )
314327 { }
@@ -317,7 +330,7 @@ internal virtual void OnPreCull()
317330 /// Unity: Update is called every frame, if the MonoBehaviour is enabled.
318331 ///
319332 /// Trigger: This is usually where you stick all your control inputs, keyboard handling, etc
320- /// See this for info on order of execuction: http ://docs.unity3d.com/Documentation /Manual/ExecutionOrder.html
333+ /// See this for info on order of execution: https ://docs.unity3d.com/Manual/ExecutionOrder.html
321334 /// </summary>
322335 internal virtual void Update ( )
323336 { }
@@ -326,7 +339,7 @@ internal virtual void Update()
326339 /// Unity Help: This function is called when the MonoBehaviour will be destroyed..
327340 ///
328341 /// Trigger: Override this for destruction and cleanup code
329- /// See this for info on order of execuction: http ://docs.unity3d.com/Documentation /Manual/ExecutionOrder.html
342+ /// See this for info on order of execution: https ://docs.unity3d.com/Manual/ExecutionOrder.html
330343 /// </summary>
331344 internal virtual void OnDestroy ( )
332345 {
0 commit comments