void OnLoadClicked()
    {
#if UNITY_STANDALONE_WIN
        var path = FileDialogForWindows.FileDialog("open VRM", ".vrm");
#else
        var path = Application.dataPath + "/default.vrm";
#endif
        if (string.IsNullOrEmpty(path))
        {
            return;
        }

        var bytes = File.ReadAllBytes(path);
        // なんらかの方法でByte列を得た

        var context = new VRMImporterContext(UniGLTF.UnityPath.FromFullpath(path));

        // GLB形式でJSONを取得しParseします
        context.ParseGlb(bytes);


        // metaを取得(todo: thumbnailテクスチャのロード)
        var meta = context.ReadMeta();
        Debug.LogFormat("meta: title:{0}", meta.Title);

        // ParseしたJSONをシーンオブジェクトに変換していく
        LoadAsync(context);
    }
    public void SaveFile()
    {
        string title = "请选择保存的位置:";
        string msg   = string.Empty;
        string path  = FileDialogForWindows.SaveDialog(title, Path.Combine(Application.streamingAssetsPath, "你要保存的文件名称.RAR"));//假如你存rar文件。

        if (!string.IsNullOrEmpty(path))
        {
            msg = "保存文件的路径为: " + path;
        }
        else
        {
            msg = "用户取消保存!";
        }
        text.text = msg;
    }
    public void OpenFile()
    {
        string title = "请选择打开的文件:";
        string msg   = string.Empty;
        string path  = FileDialogForWindows.FileDialog(title, "exe");

        if (!string.IsNullOrEmpty(path))
        {
            msg = "指定的文件路径为: " + path;
        }
        else
        {
            msg = "用户未作选择!";
        }
        text.text = msg;
    }
    void OnExportClicked()
    {
//#if UNITY_STANDALONE_WIN
#if false
        var path = FileDialogForWindows.SaveDialog("save VRM", Application.dataPath + "/export.vrm");
#else
        var path = Application.dataPath + "/../export.vrm";
#endif
        if (string.IsNullOrEmpty(path))
        {
            return;
        }

        var vrm   = VRMExporter.Export(m_model);
        var bytes = vrm.ToGlbBytes();
        File.WriteAllBytes(path, bytes);
        Debug.LogFormat("export to {0}", path);
    }
示例#5
0
        /// <summary>
        /// メタが不要な場合のローダー
        /// </summary>
        void LoadVRMClicked_without_meta()
        {
#if UNITY_STANDALONE_WIN
            var path = FileDialogForWindows.FileDialog("open VRM", ".vrm");
#else
            var path = Application.dataPath + "/default.vrm";
#endif
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

#if true
            var bytes = File.ReadAllBytes(path);
            // なんらかの方法でByte列を得た

            if (m_loadAsync)
            {
                // ローカルファイルシステムからロードします
                VRMImporter.LoadVrmAsync(bytes, OnLoaded);
            }
            else
            {
                var root = VRMImporter.LoadFromBytes(bytes);
                OnLoaded(root);
            }
#else
            // ParseしたJSONをシーンオブジェクトに変換していく
            if (m_loadAsync)
            {
                // ローカルファイルシステムからロードします
                VRMImporter.LoadVrmAsync(path, OnLoaded);
            }
            else
            {
                var root = VRMImporter.LoadFromPath(path);
                OnLoaded(root);
            }
#endif
        }
示例#6
0
        void OnOpenClicked()
        {
#if UNITY_STANDALONE_WIN
            var path = FileDialogForWindows.FileDialog("open VRM", "vrm", "glb");
#else
            var path = Application.dataPath + "/default.vrm";
#endif
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            var ext = Path.GetExtension(path).ToLower();
            switch (ext)
            {
            case ".gltf":
            case ".glb":
            case ".vrm":
                LoadModel(path);
                break;
            }
        }
示例#7
0
        public void OpenVRM()
        {
            // 環境依存: ファイルを開く
#if UNITY_EDITOR
            var path = EditorUtility.OpenFilePanel("Open VRM file", "", "vrm");
#if UNITY_EDITOR_WIN
            path = "file:///" + path;
#else
            path = "file://" + path;
#endif
#elif UNITY_STANDALONE_WIN
            var path = FileDialogForWindows.FileDialog("open VRM", ".vrm");
            path = "file:///" + path;
#else
            var path = Application.dataPath + "/default.vrm";
            path = "file:///" + path;
#endif
            if (path.Length != 0)
            {
                StartCoroutine(LoadVRMCoroutine(path));
            }
        }
示例#8
0
    void OnOpenClicked()
    {
        var path = FileDialogForWindows.FileDialog("VRMを選択してください", "vrm");

        if (string.IsNullOrEmpty(path))
        {
            return;
        }
        Debug.Log(path);
        // 小文字に直して大文字と小文字の判別を無視する
        var file_extention = Path.GetExtension(path).ToLower();

        if (file_extention == ".vrm")
        {
            var s_sceneController = GameObject.Find("SceneController").GetComponent <SceneController>();
            s_sceneController.path = path;
            // LoadVRMSceneに遷移する
            s_sceneController.LoadScene("LoadVRM");
        }
        else
        {
            Debug.LogWarningFormat("unknown file type: {0}", path);
        }
    }
示例#9
0
        public async void OpenVRM()
        {
            // 環境依存: ファイルを開く
#if UNITY_EDITOR
            var path = EditorUtility.OpenFilePanel("Open VRM file", "", "vrm");
#if UNITY_EDITOR_WIN
            path = "file:///" + path;
#else
            path = "file://" + path;
#endif
#elif UNITY_STANDALONE_WIN
            var path = FileDialogForWindows.FileDialog("open VRM", ".vrm");
            path = "file:///" + path;
#else
            var path = Application.dataPath + "/default.vrm";
            path = "file:///" + path;
#endif
            if (path.Length != 0)
            {
                var   www = new WWW(path);
                await www;
                LoadVRM(www.bytes);
            }
        }
示例#10
0
    /// <summary>
    /// VRMファイル選択ダイアログを開く
    /// </summary>
    /// <returns></returns>
    string AskVRMPath()
    {
        var path = FileDialogForWindows.FileDialog("使用するアバターを選択してください", ".vrm");

        return(string.IsNullOrEmpty(path) ? null : path);
    }