Browse Source

Fix node path behaviour on windows

Jason0214 6 năm trước cách đây
mục cha
commit
8cfeff7dd2
1 tập tin đã thay đổi với 7 bổ sung2 xóa
  1. 7 2
      io_scene_godot/structures.py

+ 7 - 2
io_scene_godot/structures.py

@@ -160,7 +160,7 @@ class NodeTemplate(FileEntry):
         self.parent = parent_node
 
         # filter out special character
-        node_name = name.replace('.', '').replace('/', '')
+        node_name = name.replace('.', '').replace('/', '').replace('\\', '')
 
         if parent_node is not None:
             # solve duplication
@@ -308,7 +308,12 @@ class NodePath:
     """Node in scene points to other node or node's attribute,
     for example, a MeshInstane points to a Skeleton. """
     def __init__(self, from_here, to_there, attribute_pointed=''):
-        self.relative_path = os.path.relpath(to_there, from_here)
+        self.relative_path = os.path.normpath(
+            os.path.relpath(to_there, from_here)
+        )
+        if os.sep == '\\':
+            # Ensure node path use '/' on windows as well
+            self.relative_path = self.relative_path.replace('\\', '/')
         self.attribute_name = attribute_pointed
 
     def new_copy(self, attribute=None):