Browse Source

Override prefab node name from script

Josh Engebretson 10 years ago
parent
commit
a6cc1d11db
1 changed files with 4 additions and 1 deletions
  1. 4 1
      Source/AtomicJS/Javascript/JSScene.cpp

+ 4 - 1
Source/AtomicJS/Javascript/JSScene.cpp

@@ -222,11 +222,14 @@ static int Node_CreateChildPrefab(duk_context* ctx)
     duk_push_this(ctx);
     duk_push_this(ctx);
     Node* parent = js_to_class_instance<Node>(ctx, -1, 0);
     Node* parent = js_to_class_instance<Node>(ctx, -1, 0);
 
 
-    Node* node = parent->CreateChild(childName);
+    Node* node = parent->CreateChild();
 
 
     PrefabComponent* prefabComponent = node->CreateComponent<PrefabComponent>();
     PrefabComponent* prefabComponent = node->CreateComponent<PrefabComponent>();
     prefabComponent->SetPrefabGUID(prefabName);
     prefabComponent->SetPrefabGUID(prefabName);
 
 
+    // override what node name is in prefab
+    node->SetName(childName);
+
     js_push_class_object_instance(ctx, node, "Node");
     js_push_class_object_instance(ctx, node, "Node");
 
 
     return 1;
     return 1;