UnityWebPlayer打开文件

来源:互联网 发布:爱淘宝精品推荐 编辑:程序博客网 时间:2024/06/07 05:10
 /// <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());    }}
0 0