블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2738)
Unity3D (817)
Script (91)
Extensions (14)
Effect (3)
NGUI (77)
UGUI (8)
Physics (2)
Shader (36)
Math (1)
Design Pattern (2)
Xml (1)
Tips (200)
Link (22)
World (1)
AssetBundle (25)
Mecanim (2)
Plugins (70)
Trouble Shooting (68)
Encrypt (7)
LightMap (4)
Shadow (4)
Editor (8)
Crash Report (3)
Utility (9)
UnityVS (2)
Facebook SDK (2)
iTween (3)
Font (11)
Ad (14)
Photon (2)
IAP (1)
Google (8)
Android (45)
iOS (41)
Programming (475)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-29 11:53

Unity3D WebView

Unity3D/Plugins / 2015. 1. 21. 17:46

Unity 3D에서 WebView를 쓸 때 유용한 소스 입니다. 

일본 개발자분이 오픈소스로 라이센스로 공개한 것 같더군요...


[소스]

https://github.com/gree/unity-webview


- Java로 작성된 Android 용 Native Plugin

- Objective-C로 작성된 iOS 용 Native Plugin

- Objective-C로 작성된 OS X 용 Native Plugin

- Native Plugin을 사용하기위한 C # Plugin


[예제 프로젝트]

https://github.com/keijiro/unity-webview-integration


unity-webview-integration 소스는 웹 페이지를 WebView로 호출에서 아래와 같이 unity와 기능을 연동한 예제 입니다.

javascript 예제여서 좀 아쉽네요. C#으로 수정해봐야 겠습니다.


http://keijiro.github.com/unity-webview-integration/index.html#

...

<title>Unity - WebView Integration Test Page</title>

<p><ul>

<li><a href="#" onclick='unity.callback("/spawn")'>Spawn a box</a></li>

<li><a href="#" onclick='unity.callback("/spawn", {color:"red"})'>Spawn a red box</a></li>

<li><a href="#" onclick='unity.callback("/spawn", {color:"blue"})'>Spawn a blue box</a></li>

<li><a href="#" onclick='unity.callback("/spawn", {color:"red", scale:0.5})'>Spawn a small red box</a></li>

<li><a href="#" onclick='unity.callback("/spawn", {color:"blue", scale:0.5})'>Spawn a small blue box</a></li>

<li><a href="#" onclick='unity.callback("/note", {text:"こんにちは"})'>「こんにちは」</a></li>

<li><a href="#" onclick='unity.callback("/note", {text:"ごきげんいかが"})'>「ごきげんいかが」</a></li>

<li><a href="#" onclick='unity.callback("/note", {text:"!@#$%^&*()-+"})'>"!@#$%^&*()-+"</a></li>

<li><a href="#" onclick='unity.callback("/close")'>Close</a></li>

<li><a href="page2.html">Go to page 2.</a></li>

</ul></p>

...


TestInterface.js (unity 3d script)

...

// Process messages coming from the web view.

private function ProcessMessages() {

    while (true) {

        // Poll a message or break.

        var message = WebMediator.PollMessage();

        if (!message) break;


        if (message.path == "/spawn") {

            // "spawn" message.

            if (message.args.ContainsKey("color")) {

                var prefab = (message.args["color"] == "red") ? redBoxPrefab : blueBoxPrefab;

            } else {

                prefab = Random.value < 0.5 ? redBoxPrefab : blueBoxPrefab;

            }

            var box = Instantiate(prefab, redBoxPrefab.transform.position, Random.rotation) as GameObject; 

            if (message.args.ContainsKey("scale")) {

                box.transform.localScale = Vector3.one * float.Parse(message.args["scale"] as String);

            }

        } else if (message.path == "/note") {

            // "note" message.

            note = message.args["text"] as String;

        } else if (message.path == "/print") {

            // "print" message.

            var text = message.args["line1"] as String;

            if (message.args.ContainsKey("line2")) {

                text += "\n" + message.args["line2"] as String;

            }

            Debug.Log(text);

            Debug.Log("(" + text.Length + " chars)");

        } else if (message.path == "/close") {

            // "close" message.

            DeactivateWebView();

        }

    }

}

...



// C#으로 변환한 소스 입니다.  by asuss님(출처 : http://reysion.tistory.com/34 의 댓글)

using UnityEngine;
using System.Collections;

public class TestWebView : MonoBehaviour {

public GUISkin guiSkin;
public GameObject redBoxPrefab;
public GameObject blueBoxPrefab;

private string note;

// Show the web view (with margins) and load the index page.
void ActivateWebView() {
WebMediator.LoadUrl("http://keijiro.github.com/unity-webview-integration/index.html");
WebMediator.SetMargin(12, Screen.height / 2 + 12, 12, 12);
WebMediator.Show();
}

// Hide the web view.
void DeactivateWebView() {
WebMediator.Hide();
// Clear the state of the web view (by loading a blank page).
WebMediator.LoadUrl("about:blank");
}

// Process messages coming from the web view.
void ProcessMessages() {
while (true) {
// Poll a message or break.
WebMediatorMessage message = WebMediator.PollMessage();
if (message == null) 
break;

if (message.path == "/spawn") {
// "spawn" message.
GameObject prefab = null;
if (message.args.ContainsKey("color")) {
prefab = (message.args["color"] == "red") ? redBoxPrefab : blueBoxPrefab;
} else {
prefab = Random.value < 0.5 ? redBoxPrefab : blueBoxPrefab;
}
var box = Instantiate(prefab, redBoxPrefab.transform.position, Random.rotation) as GameObject; 
if (message.args.ContainsKey("scale")) {
box.transform.localScale = Vector3.one * float.Parse(message.args["scale"] as string);
}
} else if (message.path == "/note") {
// "note" message.
note = message.args["text"] as string;
} else if (message.path == "/print") {
// "print" message.
var text = message.args["line1"] as string;
if (message.args.ContainsKey("line2")) {
text += "\n" + message.args["line2"] as string;
}
Debug.Log(text);
Debug.Log("(" + text.Length + " chars)");
} else if (message.path == "/close") {
// "close" message.
DeactivateWebView();
}
}
}

void Start() {
WebMediator.Install();
}

void Update() {
if (WebMediator.IsVisible()) {
ProcessMessages();
} else if (Input.GetButtonDown("Fire1") && Input.mousePosition.y < Screen.height / 2) {
ActivateWebView();
}
}

void OnGUI() {
float sw = Screen.width;
float sh = Screen.height;
GUI.skin = guiSkin;
if(note != null) 
GUI.Label(new Rect(0, 0, sw, sh/2), note);
GUI.Label(new Rect(0, sh/2, sw, sh/2), "TAP HERE", "center");
}
}



출처 : http://reysion.tistory.com/34

반응형
Posted by blueasa
, |


참조1 : http://www.devkorea.co.kr/bbs/board.php?bo_table=m03_qna&wr_id=29578


참조2 : http://wiki.unity3d.com/index.php/HtmlTexturePlugin


참조3 : http://labs.awesomium.com/unity3d-integration-tutorial-part-1/

반응형

'Unity3D > Plugins' 카테고리의 다른 글

UniWebView - Integrating WebView to your mobile games in a simple way  (0) 2015.01.21
Unity3D WebView  (0) 2015.01.21
Loading DDS, BMP, TGA and other textures via WWW class in Unity3d  (0) 2014.04.11
Log Viewer  (0) 2014.01.09
Mobile Movie Texture  (0) 2013.12.03
Posted by blueasa
, |

WWW로 Texture를 다운받을 때, DDS, BMP,TGA는 다운이 안되길래 검색해보니..

WWW로는 PNG, JPG만 된다고 한다..

다른 포멧도 지원해주는 플러그인이 있길래 링크해놓는다.


Task #5: Loading DDS, BMP, TGA and other textures via WWW class in Unity3d

  
  This article describes the task: Load images via WWW class. Current version of Unity3d allows you to download images via WWW class only in PNG or JPG format (read more here:http://docs.unity3d.com/Documentation/ScriptReference/WWW-texture.html). But we should implement image loading in such formats as DDS, BMP, GIF, PSD, TGA etc. 


  Demo of application is shown on fig. 1.
Figure 1. – Demo of application
  
  All these image formats are supported by DevIL library (read more here:http://openil.sourceforge.net/features.php).
  There is no need for full application description, because DevIL library is well documented and has a lot of examples. I will show only the short description of implementation:
  • Load texture using WWW class;
  • Get bytes data using «bytes» field of WWW class;
  • Create DevIL texture from this data;
  • Get Color32[] array from DevIL texture;
  • Create Texture2D object based on this color array;

  To illustrate implementation I created a demo application. I want to notice that this application loads also MipMaps data from the texture, and creates proper Texture2D. 
  If you need more detailed description, or implement image loading not supported by unity3d, please write it in comments.


  Application demo you can download here:
  Source code you can download from here:



출처 : http://denis-potapenko.blogspot.kr/2013/04/task-5-loading-dds-bmp-tga-and-other.html

반응형

'Unity3D > Plugins' 카테고리의 다른 글

Unity3D WebView  (0) 2015.01.21
유니티 3D상에서 WebView 띄우기  (0) 2015.01.20
Log Viewer  (0) 2014.01.09
Mobile Movie Texture  (0) 2013.12.03
원격 로그 플러그인  (0) 2013.11.20
Posted by blueasa
, |

Log Viewer

Unity3D/Plugins / 2014. 1. 9. 14:06

가장 좋은 점은 실시간 디버깅이겠죠 역시..


일단 로그를 많이 사용들 하실텐데요..

로그를 보려면 결국 디바이스를 PC나 맥에 물려야 한다는 단점도 있습니다. 

내부적으로 인게임에서 로그를 볼 수 있는 뷰어를 만드시는 분들도 있으시겠죠.. 저도 만들려고 보니까 어셋스토어에 이미 잘 만들어진게 올라와 있더라구요..


로그 창을 띄우는 방법은 코드를 보니 터치를 한 상태에서 원을 그리는 제스쳐를 취하면 뜨는데.. 이게 Orbit Camera 같은 것을 회전시킬 때나 스크롤을 잡고 돌리다 보면 너무 자주 떠서.. 터치를 하나를 감지 하는 것에서 2개 터치 이상으로 변경하시는게 좋습니다.

장점은 팀원이 갑자기 이거 안돼요! 라고 할 때 평소에 로그를 꼼꼼히 남기셨으면 바로 팀원의 폰에서 로그를 보고 그 자리에서 문제가 무엇인지 확인이 가능합니다.. 어떤 상황인지 보고 원인 분석 하고 로그 남기고 하는 것보단 훨씬 편하더라구요..



출처 : 게임코디 Kell님


반응형

'Unity3D > Plugins' 카테고리의 다른 글

유니티 3D상에서 WebView 띄우기  (0) 2015.01.20
Loading DDS, BMP, TGA and other textures via WWW class in Unity3d  (0) 2014.04.11
Mobile Movie Texture  (0) 2013.12.03
원격 로그 플러그인  (0) 2013.11.20
IronPython  (0) 2013.10.06
Posted by blueasa
, |

Mobile Movie Texture

Unity3D/Plugins / 2013. 12. 3. 15:54

Full Version
Demo Version (Same api. Works on all platforms, Windows/OSX/iOS/Android, but watermarks the decoded video)

Play ogg theora encoded videos on a texture in your iPhone/iPad/Android projects.

Changes

Version 1.1.6 29/10/2012
  • Android: Support streaming from OBB automatically.


Version 1.1.5 23/08/2012
  • All platforms: Add a split alpha demo+shader to have a seperate alpha channel in your videos. Chroma keying works well for cutting out people but doesn't work well for a lot of semi transparent things, like particles. Split alpha works well for semi transparent stuff.
  • iOS/Android: Fixed the CrCb channels not lining up properly with videos that have half sized CrCb buffers. Thanks to android_dev for the example.
  • All platforms: Fixed video picture offsets. Thanks to Bryan @ Annosoft for the example.
  • All platforms: Fixed the infinite loop if you didn't have a onFinish delegate.
  • iOS/Android: About a 15% performance improvement up in mobile shaders


Version 1.1.4 21/04/2012
  • All platforms: Add frame skipping when video is decoding too slowly
  • All platforms: Add a color tintable transparent shader
  • All platforms: Fix some transparent tags in shaders


Version 1.1.3 7/02/2012
  • All Platforms: fix a looping bug
  • All Platforms: fix a warning in the chroma key editor
  • iOS: Add XCode 3.2.X version of the lib
  • Reorganise the package so the Plugins and Streaming Assets are in the correct place


Version 1.1.2 16/01/2011
  • All Platforms: Added a chroma key shader, editor and sample
  • iOS/Android: Fixed corruption issue with a GL.InvalidateState
  • All Platforms: Fixed 2 memory leaks in the native code
  • All Platforms: Fixed YCrCb naming in the shaders


Version 1.1.1 28/12/2011
  • iOS/Android: Work around a texture allocation bug in Unity if nothing else is drawing in the sample scene, by drawing a gui button


Version 1.1 27/12/2011
  • All: platforms now do color space conversion on the gpu. This resulted in a 2x performance increase in iOS and a 1.7x in Android, in my tests.
  • All: There is a big memory saving from not storing the converted 16bit rgb in ram. For example for the test movies, we saved NextPow2(640) * NextPow2(360) * 2 bytes = 1Mb
  • Android: now has cpu features detection and uses NEON instructions where available. iOS always uses NEON.
  • Windows/OSX: use power of 2 YCrCb textures for a massive speed up.
  • Windows/OSX: use SetPixels32 for another speed up.
  • All: Removing the color space conversion code saved ~10k
  • Android: Fixed a bug on when resuming
  • Windows/OSX: Hand code the YCrCb shader to work around bad cgsl compilation by Unity


Known issues

  • iOS: Only supports armv7 (not 3G)
  • Android: There is an intermittent crash in the Adreno 200 OpenGL driver on my Nexus one, it crashes deep within the Areno driver in my call to glTexSubImage2D, in rb_texture_find_eviction_candidate in __memcmp16.




Will post videos ASAP


MobileMovieTextureDemo1.1.1.unitypackage



출처 : http://forum.unity3d.com/threads/115885-Mobile-Movie-Texture

반응형

'Unity3D > Plugins' 카테고리의 다른 글

Loading DDS, BMP, TGA and other textures via WWW class in Unity3d  (0) 2014.04.11
Log Viewer  (0) 2014.01.09
원격 로그 플러그인  (0) 2013.11.20
IronPython  (0) 2013.10.06
UniPython  (0) 2013.10.06
Posted by blueasa
, |
유니티로 개발 하다보면 유니티 플레이에서는 문제가 없거나 잘되던것들이 실제 빌드 후에는 안되거나 다른 문제가 발생하는걸 경험 합니다. 유니티에서 제공해주는 로그 콘솔을 이용해서 볼수 있다면 그나마 좀더 빠른 수정이 가능하겠지만. 유니티에서 제공하는 로그콘솔은 오직 에디터로 플레이 할때만 볼수 있습니다. 
아래 공유해드리는 플러그인을 이용하면, 빌드가 완료된 프로그램을 네트워크로 접속하여, 로그를 쉽게 볼수 있습니다. 필요하신분은 가져다 쓰시길 바랍니다.


반응형

'Unity3D > Plugins' 카테고리의 다른 글

Log Viewer  (0) 2014.01.09
Mobile Movie Texture  (0) 2013.12.03
IronPython  (0) 2013.10.06
UniPython  (0) 2013.10.06
iOS 플러그인 제작  (0) 2013.09.15
Posted by blueasa
, |

IronPython

Unity3D/Plugins / 2013. 10. 6. 21:02

Link : http://ironpython.net/

반응형

'Unity3D > Plugins' 카테고리의 다른 글

Mobile Movie Texture  (0) 2013.12.03
원격 로그 플러그인  (0) 2013.11.20
UniPython  (0) 2013.10.06
iOS 플러그인 제작  (0) 2013.09.15
Prefactory: Free PoolManager / PoolObject System  (0) 2013.08.28
Posted by blueasa
, |

UniPython

Unity3D/Plugins / 2013. 10. 6. 20:25


Link : http://forum.unity3d.com/threads/190418-UniPython-Python-Scripting-in-Unity3D-based-games

반응형

'Unity3D > Plugins' 카테고리의 다른 글

Mobile Movie Texture  (0) 2013.12.03
원격 로그 플러그인  (0) 2013.11.20
IronPython  (0) 2013.10.06
iOS 플러그인 제작  (0) 2013.09.15
Prefactory: Free PoolManager / PoolObject System  (0) 2013.08.28
Posted by blueasa
, |


링크 : http://unitystudy.net/bbs/board.php?bo_table=dustin&wr_id=402&page=0&sca=&sfl=&stx=&spt=0&page=0&cwin=#c_406

반응형

'Unity3D > Plugins' 카테고리의 다른 글

Mobile Movie Texture  (0) 2013.12.03
원격 로그 플러그인  (0) 2013.11.20
IronPython  (0) 2013.10.06
UniPython  (0) 2013.10.06
Prefactory: Free PoolManager / PoolObject System  (0) 2013.08.28
Posted by blueasa
, |



링크 : http://www.booncotter.com/unity-prefactory-a-better-pool-manager/


참조 : http://forum.unity3d.com/threads/127997-Prefactory-Free-PoolManager-PoolObject-System

반응형

'Unity3D > Plugins' 카테고리의 다른 글

Mobile Movie Texture  (0) 2013.12.03
원격 로그 플러그인  (0) 2013.11.20
IronPython  (0) 2013.10.06
UniPython  (0) 2013.10.06
iOS 플러그인 제작  (0) 2013.09.15
Posted by blueasa
, |