查看: 2333|回复: 65

[脚本] Awesomium结合Unity3D实现显示网页的效果代码

[复制链接]

34

主题

8

听众

468

积分

小学生

Rank: 2

升级   89.33%

发表于 2012-12-21 19:19 |显示全部楼层
共享资源获取更多积分!share your resources get more credits!

在unity3d中显示网页的效果实现又多了一个不错的选择,下面是一个简介的使用教程!
This a quick introductory tutorial to using Awesomium with Unity3D.

We’ll walk you through the basics and demonstrate how to display a simple web-page in your 3D scene.


[/url]Checklist

Before we start, you will need the following things:


Adding Awesomium to Unity3D on Windows:

We will first need to install the Awesomium SDK and then copy over some files so our scripts will run within the Unity3D editor:

  • Install the Awesomium SDK using the default settings (should create a new folder on your Desktop)
  • Open the awesomium_v1.6.x_sdk_win folder and navigate to build\bin\release.
  • Copy everything from the release folder  to C:\Program Files\Unity\Editor (or for **-bit Windows, copy it to C:\Program Files (x86)\Unity\Editor)

Now the Unity Editor has access to Awesomium, allowing you to use it while you debug scenes.

Adding Awesomium to Unity3D on Mac:

We will first need to install the Awesomium SDK and then copy over some files so our scripts will run within the Unity3D editor:

  • Install and mount the Awesomium SDK
  • Open up the mounted SDK folder and navigate to build/bin/release
  • Copy Awesomium.framework to /Applications/Unity/Unity.app/Contents/Frameworks(you’ll need to right-click Unity -> Show Package Contents)

Now the Unity Editor has access to Awesomium, allowing you to use it while you debug scenes.

Setting Up Your Unity3D Project:

Now it’s time to setup a new Unity3D project, add our plane object and directional light object.

  • Create a new folder on your Desktop and name it UnityAweDemo
  • Open Unity3D, go to File -> New Project -> Browse -> select the UnityAweDemo folder ->Create
  • Create a plane object by clicking GameObject -> Create Other -> Plane
  • Edit the plane’s properties in the Inspector pane (see screenshot below)

[/url]

The plane's Inspector properties

We now need to create a light source for our scene.

[url=http://labs.awesomium.com/wp-content/uploads/Screen-shot-2011-06-02-at-1.59.37-AM.png]

The directional light's Inspector properties


Adding Our Scripts:

Last, we’ll need to add AwesomiumMono.dll and the C# scripts included in the UnityAwe wrapper to our Unity3D project.

  • Download UnityAwe from https://github.com/khrona/UnityAwe/zipball/master
  • Unzip the UnityAwe archive.
  • Open it up and find the correct AwesomiumMono.dll for your platform (we have two separate builds for Windows and Mac).
  • Click and drag AwesomiumMono.dll to the Project pane in the Unity Editor.
  • Click and drag WebTexture.cs and WebCoreHelper.cs to the Project pane in the Unity3D editor.

Sweet, now your project is all set-up to use Awesomium! To actually make our plane display a web-page we just need to do two final steps:

  • Click and drag the WebTexture.cs script from the Project pane onto the Plane game object in the Hierarchy pane.
  • You should now see a Web Texture (Script) section in the Inspector pane, feel free to modify any of the default fields (such as Initial URL).

Awesome, you’re done!

Press the Play button and you should see a your Plane displaying a web-page. You should be able to interact with it like normal (mouse clicks, keyboard, etc.).

[/url]

An Interactive webpage inside the Unity Editor

Extra Tips and Tricks:
  • You can click and drag WebTexture.cs to almost any Game Object to make it display a web-page as its texture.
  • When adding it to a GUI Element make sure to make the Width and Height (see the Pixel Inset) matches the values defined in your Web Texture (Script).
  • When adding it to any other object (like a Cylinder or Sphere), make sure that it uses a Mesh Collider so that mouse input works correctly.

We will be continuing this tutorial in Part 2 with a more advanced example (scripting and HTML GUI goodness).
转自:[url=http://labs.awesomium.com/unity3d-integration-tutorial-part-1/]http://labs.awesomium.com/unity3d-integration-tutorial-part-1/

If you need any help, drop us a line in our support forum: http://support.awesomium.com


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

楼主热帖
北京真冷

2

主题

17

听众

202

积分

小学生

Rank: 2

升级   0.67%

发表于 2017-3-9 11:55 |显示全部楼层
很不错
回复

使用道具 举报

0

主题

10

听众

203

积分

小学生

Rank: 2

升级   1%

发表于 2017-3-9 11:51 |显示全部楼层
说的非常好
回复

使用道具 举报

0

主题

11

听众

204

积分

小学生

Rank: 2

升级   1.33%

发表于 2017-3-9 11:49 |显示全部楼层
很好哦
回复

使用道具 举报

5

主题

17

听众

201

积分

小学生

Rank: 2

升级   0.33%

发表于 2017-3-9 12:16 |显示全部楼层
不错不错
回复

使用道具 举报

0

主题

17

听众

203

积分

小学生

Rank: 2

升级   1%

发表于 2017-3-9 12:09 |显示全部楼层
LZ真是人才
回复

使用道具 举报

0

主题

17

听众

202

积分

小学生

Rank: 2

升级   0.67%

发表于 2017-7-2 21:34 |显示全部楼层
很不错
回复

使用道具 举报

0

主题

17

听众

201

积分

小学生

Rank: 2

升级   0.33%

发表于 2017-7-2 21:07 |显示全部楼层
好帖就是要顶
回复

使用道具 举报

0

主题

17

听众

201

积分

小学生

Rank: 2

升级   0.33%

发表于 2017-7-2 20:49 |显示全部楼层
难得一见的好帖
回复

使用道具 举报

0

主题

17

听众

201

积分

小学生

Rank: 2

升级   0.33%

发表于 2017-7-2 21:01 |显示全部楼层
很好哦
回复

使用道具 举报

温馨提示:求助请到“Unity技术讨论”版块中发帖,便于集中解决!
您需要登录后才可以回帖 登录 | 立即注册

懒人模式:

关闭

站长推荐 上一条 /1 下一条

Unity3D游戏开发联盟(资源共享平台) -Unity3D,Unreal ( 苏ICP备12051100号 )   

GMT+8, 2019-8-21 17:50 , Processed in 0.083877 second(s), 44 queries .