Skip to content
HiroyukiHaga edited this page Oct 26, 2012 · 19 revisions

#LWF For Unity

Setup

Install Unity

  • Please download and install Unity3d. LWF works with free version of Unity.
  • http://unity3d.com/

Play demo project.

  1. Clone the "lwf-demo" project.
git clone [email protected]:gree/lwf-demo.git
  1. Launch Unity3d.
  2. Open Project Wizard with "File -> Open Project...", and click "Open Other..." for choosing project directory.
  3. Select "lwf-demo/unity/basic" directory. The project will be opened successfully.
  4. Double-click "Simple" icon in the "Project" tab to open an example scene.
  5. Click "Play" button in the top of menu. You will see logo, animated building and buttons.

Make your own Unity project.

Step by step video is uploaded for easy understanding. http://youtu.be/A_AhTosm1NU

  1. Clone the "lwf" project.
git clone [email protected]:gree/lwf.git
  1. Create you new Unity project.
  2. 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.
  1. Copy the proper lwf folders to proper Unity's folder.
  2. Copy "csharp/unity/editor" folder to "Editor" Editor.
  3. Copy "csharp/core" folder to "Plugins" folder
  4. Copy "csharp/unity/renderer" folder to "Plugins" folder.
  5. Copy "csharp/unity/wrapper" folder to "Plugins" folder.
  6. Copy "csharp/unity/shader" folder to "Resources" Editor.

Animal Days

  1. Clone the "lwf-demo" project for getting example flash files.
git clone [email protected]:gree/lwf-demo.git
  1. Copy "gree_logo.lwfdata" folders in "flash" folder to your Unity project's "Resources" folder.
  2. 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.

Animal Days

  1. 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;
			}
		);
	}
}
  1. Create a GameObject, and attach the "Simple" script to the newly created GameObject.
  2. Play the scene.
  3. Click "Scene" tab. You can see the icon is displayed properly. Please adjust "Main Camera" properly for displaying the icon properly in "Game" tab.

Animal Days

  1. You can find completed scene in https://github.com/gree/lwf-demo/tree/master/unity as well.

Optional: Use DLL

NOTE:
 You can use DLLs instead of C# code with following steps. Please note that debugging will be much difficult when dlls are used.
  1. 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
  1. 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.
  1. 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.
  2. Copy "shaders" folder in "csharp/unity" folder to your Unity project's "Resources" folder. Installation is completed.
Clone this wiki locally