Esempio n. 1
0
        public static GameObject Import(string modelPath)
        {
            Debug.LogFormat("import {0}", modelPath);
            if (!File.Exists(modelPath))
            {
                Debug.LogErrorFormat("Import {0} failed, file not exist.", modelPath);
                return(null);
            }

            if (Path.GetExtension(modelPath).ToLower() == ".fbx")
            {
                FBXScenePtr scene = fbxImporter.ImportFile(modelPath);
                if (scene != null && !scene.IsNull())
                {
                    return(CreateGameObject(modelPath, scene));
                }
                else
                {
                    Debug.LogWarningFormat("{0} scene is empty", modelPath);
                }
            }
            else
            {
                Debug.LogErrorFormat("Not support file format {0}", Path.GetExtension(modelPath));
            }

            return(null);
        }