Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom script for import doesn't work #12256

Closed
satyries opened this issue Oct 20, 2017 · 3 comments
Closed

Custom script for import doesn't work #12256

satyries opened this issue Oct 20, 2017 · 3 comments

Comments

@satyries
Copy link

satyries commented Oct 20, 2017

Operating system or device, Godot version, GPU Model and driver (if graphics related):

Godot on *buntu 17.04

Issue description:
Whatever script.gd (even an empty one) you put in the "Custom Script" gives generic error ( Error running post-import script ) without telling anything about what's wrong. The official Wiki says you're supposed to use this code to make it work

tool # needed so it runs in editor
extends EditorScenePostImport

func post_import(scene):

return scene # remember to return the imported scene

This code works with Godot2, but both class EditorScenePostImport and function post_import are not present in Godot3

Steps to reproduce:

  • While in Godot Editor select the item you want to import.
  • Select Import on the left box then put a script in Custom Script
  • Click Re-import
    = generic error appear, item cannot be imported anymore until you don't remove that script file

Link to minimal example project:

minidemo.zip
demo: while in editor try to reimport the box.dae

@volzhs
Copy link
Contributor

volzhs commented Oct 24, 2017

post_import is actually here.

Node *EditorScenePostImport::post_import(Node *p_scene) {
if (get_script_instance())
return get_script_instance()->call("post_import", p_scene);
return p_scene;
}

but not binded

godot/editor/editor_node.cpp

Lines 3268 to 3270 in 9f78878

// FIXME: Is this stuff obsolete, or should it be ported to new APIs?
//ClassDB::register_class<EditorScenePostImport>();
//ClassDB::register_type<EditorImportExport>();

@reduz @akien-mga is it really obsolete?

@volzhs
Copy link
Contributor

volzhs commented Oct 24, 2017

I just uncommented //ClassDB::register_class<EditorScenePostImport>();
This code works really well.

tool # needed so it runs in editor
extends EditorScenePostImport

func post_import(scene):
    # do your stuff here
    for child in scene.get_children():
        if child is MeshInstance:
            child.set_surface_material(0, preload("res://materials/my.material"))
    return scene # remember to return the imported scene

@satyries
Copy link
Author

satyries commented Oct 25, 2017

I can confirm what @volzhs said, by uncommenting that line and compiling I was able to use the post_import again.

I guess this feature is not supported atm if there's looking for new API so I won't report if any bug/issue is found while using... but still it's something nice to have: saves lot of manual work, in which, even onto unstable testing can come handy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants