ソースを参照

Node::ReorderComponent(): signed index

1vanK 3 年 前
コミット
219851c748

+ 2 - 2
Source/Urho3D/AngelScript/Generated_Members.h

@@ -15766,8 +15766,8 @@ template <class T> void RegisterMembers_Node(asIScriptEngine* engine, const char
     // bool Node::RemoveTag(const String& tag)
     engine->RegisterObjectMethod(className, "bool RemoveTag(const String&in)", AS_METHODPR(T, RemoveTag, (const String&), bool), AS_CALL_THISCALL);
 
-    // void Node::ReorderComponent(Component* component, unsigned index)
-    engine->RegisterObjectMethod(className, "void ReorderComponent(Component@+, uint)", AS_METHODPR(T, ReorderComponent, (Component*, unsigned), void), AS_CALL_THISCALL);
+    // void Node::ReorderComponent(Component* component, i32 index)
+    engine->RegisterObjectMethod(className, "void ReorderComponent(Component@+, int)", AS_METHODPR(T, ReorderComponent, (Component*, i32), void), AS_CALL_THISCALL);
 
     // void Node::ResetDeepEnabled()
     engine->RegisterObjectMethod(className, "void ResetDeepEnabled()", AS_METHODPR(T, ResetDeepEnabled, (), void), AS_CALL_THISCALL);

+ 3 - 1
Source/Urho3D/Scene/Node.cpp

@@ -1061,8 +1061,10 @@ void Node::RemoveAllComponents()
     RemoveComponents(true, true);
 }
 
-void Node::ReorderComponent(Component* component, unsigned index)
+void Node::ReorderComponent(Component* component, i32 index)
 {
+    assert((index >= 0 && index < components_.Size()) || index == ENDPOS);
+
     if (!component || component->GetNode() != this)
         return;
 

+ 4 - 2
Source/Urho3D/Scene/Node.h

@@ -318,8 +318,10 @@ public:
     void RemoveComponents(StringHash type);
     /// Remove all components from this node.
     void RemoveAllComponents();
-    /// Adjust index order of an existing component in this node.
-    void ReorderComponent(Component* component, unsigned index);
+
+    /// Adjust index order of an existing component in this node. index can be ENDPOS.
+    void ReorderComponent(Component* component, i32 index);
+
     /// Clone scene node, components and child nodes. Return the clone.
     Node* Clone(CreateMode mode = REPLICATED);
     /// Remove from the parent node. If no other shared pointer references exist, causes immediate deletion.