찾기
내용으로 건너뛰기
추적
문서의 이전 판을 선택했습니다!
저장하면 이 자료로 새 판을 만듭니다.
미디어 파일
======Flash: Embedding Unity Generated Flash Content in Larger Flash Projects====== If you want to embed your Unity generated Flash content within a larger Flash project, you can do so using the ''UnityShared.swc''. This SWC provides functionality to load and communicate with Unity published Flash content. When your Unity Flash project is built, a copy of the UnityShared.swc file will be placed in the same location as your built SWF. You can then use this in your Flash projects as per other SWCs. For more details on [[http://www.adobe.com/mena_fr/devnet/flash/articles/concept_swc.html|what SWCs are]] and how to use them, see [[http://livedocs.adobe.com/flex/3/html/help.html?content=building_overview_5.html|Adobe’s documentation]]. \\ =====UnityShared.swc Contents===== In the ''UnityShared.swc'' file, you will find two classes and two interfaces. Each of these, and their available functions, are described below. ====IUnityContent==== //IUnityContent// is implemented by Unity built Flash content. This interface is how you communicate with or modify the Untiy content. |getTextureFromNativeId(id : int) : TextureBase;|Enables retrieving of textures. A full example project using this can be found on the [[http://forum.unity3d.com/threads/128057-Flash-Simple-AS3-Bridge-Demo-Loading-textures-from-web.?p=864642&viewfull=1#post864642|forums]].| |sendMessage(objectPath : String, methodName : String, value : Object = null) : Boolean;|The //sendMessage// function can be used to call a method on an object in the Unity content.| |setContentHost(contentHost : IUnityContentHost) : void;|Sets the host (which must implement //IUnityContentHost//) for the Unity content. The host can then listen for when the Unity content has loaded/started.| |setSize(width : int, height : int) : void;|Modifies the size of the Unity content| |startFrameLoop() : void;|Starts the Unity content.| |stopFrameLoop() : void;|Stops the unity content.| \\ ====IUnityContentHost==== This must be implemented by whichever class will host the Unity content. |unityInitComplete() : void;|Called when the Unity engine is done initializing and the first level is loaded.| |unityInitStart() : void;|Called when the content is loaded and the initialization of the Unity engine is started.| \\ ====UnityContentLoader==== The //UnityContentLoader// class can be used to load Unity published Flash content. As with standard AS3 Loader instances, you can add event listeners to its //contentLoaderInfo// in order to know the progress of the load and when it is complete. <file csharp>UnityContentLoader(contentURL : String, contentHost : IUnityContentHost = null, params : UnityLoaderParams = null, autoLoad : Boolean = true) : void;</file> Creates a //UnityContentLoader// instance which you can attach event listeners to and use to load the unity content. * //contentURL//: The URL of the Unity published SWF to load. * //contentHost//: The host for the content. This should be your own ActionScript class that implements //IUnityContentHost//. * //params//: Supply a //UnityLoaderParams// instance if you wish to override the default load details. * //autoLoad//: If set to true, the load will begin as soon as the //UnityContentLoader// has been created (rather than needing to call //loadUnity()// separately). If you wish to track progress of the load using events, this should be set to false. You can then call //loadUnity()// manually once the relevant event listeners have been added. |loadUnity() : void;|Instructs the //UnityContentLoader// to load the Unity content from the URL supplied in the constructor.| |unityContent : IUnityContent;|Once the content has finished loading, you can access the Unity content to perform functionality such as //sendMessage()//.| \\ ====UnityLoaderParams==== Parameters can be supplied to the //UnityContentLoader// when created to provide additional loader configuration. \\ <file csharp>function UnityLoaderParams(scaleToStage : Boolean = false, width : int = 640, height : int = 480, usePreloader : Boolean = false, autoInit : Boolean = true, catchGlobalErrors : Boolean = true) : void;</file> * //scaleToStage//: Whether the Unity content remains at a fixed size or whether it scales as the parent Flash window resizes. * //width//: The width of the Unity content. * //height//: The height of the Unity content. * //usePreloader//: Whether or not to show the Unity preloader. * //autoInit//: This is not currently used. * //catchGlobalErrors//: Whether to catch errors and display them in a red box in the top left corner of the swf. \\ =====Example===== The following example shows how to load Unity published Flash content into a host SWF. It shows how to supply custom //UnityLoaderParams// and track progress of the file load. Once the Unity content has been added to the host, a function in the Unity content is called using the //sendMessage// function. \\ <file csharp> public class MyLoader extends Sprite implements IUnityContentHost { private var unityContentLoader:UnityContentLoader; public function MyLoader() { var params:UnityLoaderParams = new UnityLoaderParams(false,720,400,false); unityContentLoader = new UnityContentLoader("UnityContent.swf", this, params, false); unityContentLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onUnityContentLoaderProgress); unityContentLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onUnityContentLoaderComplete); unityContentLoader.loadUnity(); } private function onUnityContentLoaderProgress(event:ProgressEvent):void { //Respond to load progress } private function onUnityContentLoaderComplete(event:Event):void { addChild(unityContentLoader); unityContentLoader.unityContent.setContentHost(this); } //unityInitStart has to be implemented by whatever implements IUnityContenthost //This is called when the content is loaded and the initialization of the unity engine is started. public function unityInitStart():void { //Unity engine started } //unityInitComplete has to be implemented by whatever implements IUnityContenthost //This is called when the unity engine is done initializing and the first level is loaded. public function unityInitComplete():void { unityContentLoader.unityContent.sendMessage("Main Camera","SetResponder",{responder:this}); } ... } </file> {{tag>유니티 unity}} * 출처: [[http://unitykoreawiki.com/index.php?n=KrMain.flash-unitysharedswc|유니티코리아위키]] (CC BY-NC-SA 2.0)
저장
미리 보기
취소
편집 요약
참고: 이 문서를 편집하면 내용은 다음 라이선스에 따라 배포하는 데 동의하는 것으로 간주합니다:
CC Attribution-Noncommercial-Share Alike 4.0 International
연결문서
플래시 개발 시작하기
유니티3D ( Unity3D )
문서 도구
문서 보기
이전 판
연결문서
맨 위로
다크 모드로 보기
☀️
Toggle Menu
유니티3D ( Unity3D )
너두 고쳐두 됩니다.
사이트 도구
최근 바뀜
미디어 관리자
사이트맵
사용자 도구
등록
로긴
최근 수정된 문서
4380_2755
어둠의_장막의_핵
만듦
4431_2830
4409_1227
4429_1314
[목공 야옂지 (Carpentry Camp)]
4666_3385
4593_3153
[쏜홀드 (Thornhold)]
4889_3028
4950_2900
3563_3563
3559_3674
↷ 문서 이름이 game:enshrouded:3559_3674에서 game:enshrouded:3563_3563(으)로 바뀌었습니다
3567_3496
[버려진 사냥꾼 야영지 (Carpentry Camp)]
3709_3988
3647_3776
4525_2232
[폐허가 된 네더튼]
4450_2324
4910_1627