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()
49
49
}
50
50
}
51
51
52
- void Awake ( )
52
+ public LazyConstruct ( )
53
53
{
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 > ( ) ;
63
63
}
64
64
}
65
65
66
+ void Start ( )
67
+ {
68
+ LazyConstruct ( ) ;
69
+ }
70
+
66
71
public ROS2Node CreateNode ( string name )
67
72
{
73
+ LazyConstruct ( ) ;
74
+
68
75
lock ( mutex )
69
76
{
70
77
foreach ( ROS2Node n in nodes )
@@ -97,6 +104,8 @@ public void RemoveNode(ROS2Node node)
97
104
/// </summary>
98
105
public void RegisterExecutable ( Action executable )
99
106
{
107
+ LazyConstruct ( ) ;
108
+
100
109
lock ( mutex )
101
110
{
102
111
executableActions . Add ( executable ) ;
You can’t perform that action at this time.
0 commit comments