瀏覽代碼

Add missing methods to Node class in the mono glue

* GetNodeOrNull<T>
* GetChild<T>
* GetChildOrNull<T>
* GetOwner<T>
* GetOwnerOrNull<T>
* GetParent<T>
* GetParentOrNull<T>
Paul Joannon 7 年之前
父節點
當前提交
877ea882ce
共有 2 個文件被更改,包括 36 次插入1 次删除
  1. 35 0
      modules/mono/glue/cs_files/NodeExtensions.cs
  2. 1 1
      modules/mono/glue/cs_files/VERSION.txt

+ 35 - 0
modules/mono/glue/cs_files/NodeExtensions.cs

@@ -6,5 +6,40 @@ namespace Godot
         {
         {
             return (T)GetNode(path);
             return (T)GetNode(path);
         }
         }
+
+        public T GetNodeOrNull<T>(NodePath path) where T : Godot.Node
+        {
+            return GetNode(path) as T;
+        }
+
+        public T GetChild<T>(int idx) where T : Godot.Node
+        {
+            return (T)GetChild(idx);
+        }
+
+        public T GetChildOrNull<T>(int idx) where T : Godot.Node
+        {
+            return GetChild(idx) as T;
+        }
+
+        public T GetOwner<T>() where T : Godot.Node
+        {
+            return (T)GetOwner();
+        }
+
+        public T GetOwnerOrNull<T>() where T : Godot.Node
+        {
+            return GetOwner() as T;
+        }
+
+        public T GetParent<T>() where T : Godot.Node
+        {
+            return (T)GetParent();
+        }
+
+        public T GetParentOrNull<T>() where T : Godot.Node
+        {
+            return GetParent() as T;
+        }
     }
     }
 }
 }

+ 1 - 1
modules/mono/glue/cs_files/VERSION.txt

@@ -1 +1 @@
-6
+7