asp.net web项目中引用unity3d项目

1.unity发布webGL
在这里插入图片描述
2.vs新建ASP.NET web应用程序,框架选择4.5,然后选择窗体模式
在这里插入图片描述
在这里插入图片描述

3.从文件夹将发布的webGL文件夹复制到vs新建的项目目录下
在这里插入图片描述
4.在vs项目中显示所有文件,并将unityfabu文件夹包含到项目中
在这里插入图片描述
在这里插入图片描述
5.修改config文件,添加unity相关配置
在这里插入图片描述

<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".unity3d" mimeType="application/unity" />
      <mimeMap fileExtension=".unityweb" mimeType="application/unity" />
    </staticContent>
  </system.webServer>

6.在前台页面中加入unity的引用(此处以vs新建项目的默认示例的about页面为例)

<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="UnityIntoWebTest04.About" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="shortcut icon" href="unityFabu/TemplateData/favicon.ico">
    <link rel="stylesheet" href="unityFabu/TemplateData/style.css">
    <script src="unityFabu/TemplateData/UnityProgress.js"></script>
    <script src="unityFabu/Build/UnityLoader.js"></script>

    <script>
        var gameInstance = UnityLoader.instantiate("gameContainer", "unityFabu/Build/unityFabu.json", { onProgress: UnityProgress });//UnityProgress可自定义,详情可参看Unity官方文档
    </script>

    <h2>ssss</h2>

    
        <div id="gameContainer" style="width: 960px; height: 600px"></div>
        <div class="footer">
            <div class="webgl-logo"></div>
            <div class="fullscreen" onclick="gameInstance.SetFullscreen(1)"></div>
            <div class="title">uGUIpro</div>
        </div>
  

    <h2><%: Title %>.</h2>
    <h3>Your application description page.</h3>
    <p>Use this area to provide additional information.</p>
</asp:Content>

7.发布iis运行后界面如下,unity项目在c#项目中成功引用
在这里插入图片描述

问题:解决webgl发布中文不显示问题
加入中文字体,然后更改unity中的中文字体
https://blog.csdn.net/liu442620190/article/details/82685266
我放入的是微软雅黑

Unity3D发布WebGL
https://blog.csdn.net/beihuanlihe130/article/details/77543410

原创文章 53 获赞 33 访问量 4万+

猜你喜欢

转载自blog.csdn.net/qq_35257875/article/details/96851635