首页 > 学院 > 开发设计 > 正文

UnityWebPlayer打开文件

2019-11-08 03:25:43
字体:
来源:转载
供稿:网友
/// <summary>/// 加载资源文件(格式为*.unity3d)./// </summary>/// <param name="src">The source.</param>public void OpenFile(string src){ try { if (string.IsNullOrWhiteSpace(src)) return; if (!File.Exists(src)) return; if (this.unityPlayer != null) { this.unityPlayer.Dispose(); this.unityPlayer = null; } this.unityPlayer = new AxUnityWebPlayerAXLib.AxUnityWebPlayer(); ((System.ComponentModel.ISupportInitialize)(this.unityPlayer)).BeginInit(); this.Controls.Add(this.unityPlayer); ((System.ComponentModel.ISupportInitialize)(this.unityPlayer)).EndInit(); this.unityPlayer.src = src; AxHost.State state = this.unityPlayer.OcxState; this.unityPlayer.Dispose(); this.unityPlayer = new AxUnityWebPlayerAXLib.AxUnityWebPlayer(); ((System.ComponentModel.ISupportInitialize)(this.unityPlayer)).BeginInit(); this.SuspendLayout(); this.unityPlayer.Dock = DockStyle.Fill; this.unityPlayer.Name = "viewControl1"; this.unityPlayer.OcxState = state; this.unityPlayer.TabIndex = 0; this.unityPlayer.OnExternalCall += Unity_OnExternalCall; this.panel1.Controls.Clear(); this.panel1.Controls.Add(this.unityPlayer); this.panel1.Controls.Add(this.m_logo); this.m_logo.BringToFront(); ((System.ComponentModel.ISupportInitialize)(this.unityPlayer)).EndInit(); this.ResumeLayout(false); } catch (Exception err) { Debug.WriteLine(err.ToString()); }}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表