File tree Expand file tree Collapse file tree 1 file changed +19
-10
lines changed
Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -49,22 +49,29 @@ public bool Ok()
4949 }
5050 }
5151
52- void Awake ( )
52+ private LazyConstruct ( )
5353 {
54- if ( ros2forUnity == null )
55- {
56- lock ( mutex )
57- {
58- ros2forUnity = new ROS2ForUnity ( ) ;
59- nodes = new List < ROS2Node > ( ) ;
60- ros2csNodes = new List < INode > ( ) ;
61- executableActions = new List < Action > ( ) ;
62- }
54+ lock ( mutex )
55+ {
56+ if ( ros2forUnity != null )
57+ return ;
58+
59+ ros2forUnity = new ROS2ForUnity ( ) ;
60+ nodes = new List < ROS2Node > ( ) ;
61+ ros2csNodes = new List < INode > ( ) ;
62+ executableActions = new List < Action > ( ) ;
6363 }
6464 }
6565
66+ void Start ( )
67+ {
68+ LazyConstruct ( ) ;
69+ }
70+
6671 public ROS2Node CreateNode ( string name )
6772 {
73+ LazyConstruct ( ) ;
74+
6875 lock ( mutex )
6976 {
7077 foreach ( ROS2Node n in nodes )
@@ -97,6 +104,8 @@ public void RemoveNode(ROS2Node node)
97104 /// </summary>
98105 public void RegisterExecutable ( Action executable )
99106 {
107+ LazyConstruct ( ) ;
108+
100109 lock ( mutex )
101110 {
102111 executableActions . Add ( executable ) ;
You can’t perform that action at this time.
0 commit comments