private void Start()
        {
            if (File.Exists(_LocalFilePath))
            {
                var vgoImporter = new VgoImporter();

                vgoImporter.Load(_LocalFilePath);
            }
            else
            {
                Debug.LogWarningFormat("File is not found. {0}", _LocalFilePath);
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="src"></param>
        /// <param name="prefabPath"></param>
        public static void ImportAsset(string src, UnityPath prefabPath)
        {
            if (!prefabPath.IsUnderAssetsFolder)
            {
                Debug.LogWarningFormat("out of asset path: {0}", prefabPath);
                return;
            }

            var context = new VgoImporter();

            context.Parse(src);

            // Extract textures to assets folder
            context.ExtractImages(prefabPath);

            ImportDelayed(src, prefabPath, context);
        }
Example #3
0
        /// <summary>
        /// Import VGO.
        /// </summary>
        /// <returns></returns>
        public static async Task ImportVgo()
        {
            string path = EditorUtility.OpenFilePanel(title: "Open File Dialog", directory: "", extension: "vgo");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            if (Application.isPlaying)
            {
                //
                // load into scene
                //
                var context = new VgoImporter();

                await context.LoadAsync(path, showMeshes : true, enableUpdateWhenOffscreen : true);

                Selection.activeGameObject = context.Root;
            }
            else
            {
                //
                // save as asset
                //
                if (path.StartsWithUnityAssetPath())
                {
                    Debug.LogWarningFormat("disallow import from folder under the Assets");
                    return;
                }

                string assetPath = EditorUtility.SaveFilePanel(title: "Save prefab", directory: "Assets", defaultName: Path.GetFileNameWithoutExtension(path), extension: "prefab");

                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                // import as asset
                VgoAssetPostprocessor.ImportAsset(path, UnityPath.FromFullpath(assetPath));
            }
        }