EditorScenePostImport

继承: RefCounted < Object

Post-processes scenes after import.

描述

Imported scenes can be automatically modified right after import by setting their Custom Script Import property to a tool script that inherits from this class.

The _post_import callback receives the imported scene's root node and returns the modified version of the scene. Usage example:


    @tool # Needed so it runs in editor.
    extends EditorScenePostImport
    
    # This sample changes all node names.
    # Called right after the scene is imported and gets the root node.
    func _post_import(scene):
        # Change all node names to "modified_[oldnodename]"
        iterate(scene)
        return scene # Remember to return the imported scene
    
    func iterate(node):
        if node != null:
            node.name = "modified_" + node.name
            for child in node.get_children():
                iterate(child)

    using Godot;
    
    // This sample changes all node names.
    // Called right after the scene is imported and gets the root node.
    [Tool]
    public partial class NodeRenamer : EditorScenePostImport
    {
        public override GodotObject _PostImport(Node scene)
        {
            // Change all node names to "modified_[oldnodename]"
            Iterate(scene);
            return scene; // Remember to return the imported scene
        }
    
        public void Iterate(Node node)
        {
            if (node != null)
            {
                node.Name = $"modified_{node.Name}";
                foreach (Node child in node.GetChildren())
                {
                    Iterate(child);
                }
            }
        }
    }

方法

Object_post_import ( scene: Node ) virtual1
Stringget_source_file ( ) const2

方法说明

Object _post_import ( scene: Node ) virtual1

Called after the scene was imported. This method must return the modified version of the scene.


String get_source_file ( ) const2

Returns the source file path which got imported (e.g. res://scene.dae).

1

本方法通常需要用户覆盖才能生效。

2

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。