Jump to content

[SOLVED] Import .fbx file at runtime


photo

Recommended Posts

Hi,

I am currently trying to import an .fbx-file at runtime in C# but the documentation lacks a bit of more information to do that in C# :). I have tried to follow this topic, but currently doesn't understand, what the problem was.

I have used the engine version 2.14.1.1.  As usual, I register my FBX-Importer via -extern_plugin and try to do the following:

public NodeReference LoadFileTo(String dataPath, String workspaceDirectory)
        {
            if (!bValidImportFile)
                return null;
            
            //var node_name = importer.OutputFilepath;
            var node_name = Import.DoImport(dataPath,workspaceDirectory);

            if (node_name != string.Empty)
            {
                //try to create a NodeReference

                try
                {
                    NodeReference nodeRef = new NodeReference(node_name);
                    return nodeRef;

                }
                catch (Exception e)
                {
                    Log.Message("Import Failure.");
                    Log.MessageLine(e.Message);
                }

            }


            return null;

        }

 

Unfortunately I got an error message:

ERROR:	FbxImporter::init(): can't initialize "E:/Unigine/Monitoring_Tool_Client/data/.runtimes/18/18fd1b8b0ad5bb6e3fb54bf51fd46cd01de359ef.node"
ERROR:	Fbx: Unexpected file type
ERROR:	Importer::init: Can't init importer.

I have tried it with absolute and relative path, but without any effect. When I call "Import.GetSupportedExtensions" the collection returns "FbxImporter", so this shouldn't be a problem here. The fbx-file, of course, loaded without any issues in the editor.

Do I miss something up before calling "Import.DoImport"? When doing that in C++ in other projects I need to create a new Importer, where I can define additional paramers as well. Maybe I am missining something important here? A short hint would be much appreciated.

Best

Christian

Link to comment

Thanks for the hint silent, removing the .fbx file from the data folder (was there for testing reasons) did the trick. Never thought from the error log about that could be an issue. I guess the line "can't initialize ... .node" was the hint for the already existing .fbx. file.

Link to comment
  • silent changed the title to [SOLVED] Import .fbx file at runtime
×
×
  • Create New...