-
Notifications
You must be signed in to change notification settings - Fork 167
Forunity
HiroyukiHaga edited this page Oct 26, 2012
·
19 revisions
#LWF For Unity
- Please download and install Unity3d. LWF works with free version of Unity.
- http://unity3d.com/
- Clone the "lwf-demo" project.
git clone [email protected]:gree/lwf-demo.git
- Launch Unity3d.
- Open Project Wizard with "File -> Open Project...", and click "Open Other..." for choosing project directory.
- Select "lwf-demo/unity/basic" directory. The project will be opened successfully.
- Double-click "Simple" icon in the "Project" tab to open an example scene.
- Click "Play" button in the top of menu. You will see logo, animated building and buttons.
Step by step video is uploaded for easy understanding. http://youtu.be/A_AhTosm1NU
- Clone the "lwf" project.
git clone [email protected]:gree/lwf.git
- Create you new Unity project.
- Create 3 Unity's special folders in "Project" tab such as
- "Resources" : You can access all resources in this "Resources" folder by using UnityEngine.Resources class
- "Editor" : Any scripts for Unity Editor should be under this folder.
- "Plugins" : Plugin folder.
- Copy the proper lwf folders to proper Unity's folder.
- Copy "csharp/unity/editor" folder to "Editor" Editor.
- Copy "csharp/core" folder to "Plugins" folder
- Copy "csharp/unity/renderer" folder to "Plugins" folder.
- Copy "csharp/unity/wrapper" folder to "Plugins" folder.
- Copy "csharp/unity/shader" folder to "Resources" Editor.
- Clone the "lwf-demo" project for getting example flash files.
git clone [email protected]:gree/lwf-demo.git
- Copy "gree_logo.lwfdata" folders in "flash" folder to your Unity project's "Resources" folder.
- Open your Unity project's "Resources/gree_logo.lwfdata", and rename "gree_logo.lwf" to "gree_logo.bytes". Remove gree_logo.* files except for gree_logo.bytes and gree_logo_0.png file.
- Create new C# script file name "Simple". Update the file with following code.
using UnityEngine;
using System.Collections;
public class Simple : LWFObject {
void Start()
{
setLoader();
// #1 Show popup lwf/textures
Load("gree_logo.lwfdata/gree_logo", "gree_logo.lwfdata/");
}
void setLoader()
{
LWFObject.SetLoader(
lwfDataLoader:(name) => {
TextAsset asset = Resources.Load(name) as TextAsset;
if (asset == null) {
return null;
}
return asset.bytes;
},
textureLoader:(name) => {
Texture2D texture = Resources.Load(name) as Texture2D;
if (texture == null) {
return null;
}
return texture;
}
);
}
}
- Create a GameObject, and attach the "Simple" script to the newly created GameObject.
- Play the scene.
- Click "Scene" tab. You can see the icon is displayed properly. Please adjust "Main Camera" properly for displaying the icon properly in "Game" tab.
- You can find completed scene in https://github.com/gree/lwf-demo/tree/master/unity as well.
NOTE:
You can use DLLs instead of C# code with following steps. Please note that debugging will be much difficult when dlls are used.
- Compile DLLs
lwf $: cd csharp/unity/build
lwf $: rake
(in /Users/github/lwf/csharp/unity/build)
lwf.dll:
lwf_editor.dll:
lwf $: ls
Rakefile lwf.dll.mdb lwf_editor.dll.mdb
lwf.dll lwf_editor.dll
- Create 3 Unity's special folders in "Project" tab such as
- "Resources" : You can access all resources in this "Resources" folder by using UnityEngine.Resources class
- "Editor" : Any scripts for Unity Editor should be under this folder.
- "Plugins" : Plugin folder.
- Copy the "lwf.dll" file to your Unity project's "Plugins" folder. Copy the "lwf_editor.dll" file to your Unity project's "Editor" folder.
- Copy "shaders" folder in "csharp/unity" folder to your Unity project's "Resources" folder. Installation is completed.