public ScaleformMovie(ScaleformLayer layer, SFCamera cam, SFMovieCreationParams creationParams) : base(cam.GetSFManager(), creationParams) { Layer = layer; Camera = cam; SetFocus(true); }
public void Update() { RenderTexture rtt = (GetComponent("Camera") as Camera).targetTexture; SFCamera camera = Component.FindObjectOfType(typeof(SFCamera)) as SFCamera; if (camera) { SFManager sfManager = camera.GetSFManager(); Movie movie = sfManager.GetTopMovie(); if (movie != null) { #if !(UNITY_3_5) Debug.Log("GetNativeTexturePtr: " + rtt.GetNativeTexturePtr()); sfManager.ReplaceTexture(movie.GetID(), "texture1", rtt); #endif } } }
private void Update() { if (movie == null) { if (scaleformCamera == null) { return; } var manager = scaleformCamera.GetSFManager(); if (manager == null || !manager.IsSFInitialized()) { return; } SFMovieCreationParams creationParams = SFCamera.CreateMovieCreationParams(FlashMovieFile, MovieDepth, BackgroundColor, OverrideBackgroundColor); creationParams.IsInitFirstFrame = InitFirstFrame; creationParams.TheScaleModeType = ScaleMode; movie = createMovie(creationParams); } }
public bool CreateRenderMovie(SFCamera camera, Type movieClassType) { #if !(UNITY_4_0 || UNITY_4_1) && UNITY_STANDALONE_WIN if (SystemInfo.graphicsDeviceVersion[0] == 'D') { return(false); } #endif if (RenderTexture == null) { Debug.Log("RenderTexture is null, failure to create RenderMovie. Check if you specified all the parameters properly."); return(false); } if (RTTMovie == null || RTTMovie.MovieID == 0) { if (camera) { Debug.Log("Creating movie"); SFMovieCreationParams creationParams = SFCamera.CreateRTTMovieCreationParams(SwfName, OriginX, OriginY, RenderTexture, ClearColor); creationParams.TheScaleModeType = ScaleModeType.SM_ExactFit; creationParams.IsInitFirstFrame = true; creationParams.IsAutoManageViewport = false; // Has the user specified a movie subclass? if (movieClassType != null) { SFManager sfMgr = camera.GetSFManager(); RTTMovie = Activator.CreateInstance(movieClassType, sfMgr, creationParams) as Movie; if (RTTMovie != null) { RTTMovie.SetRTT(this); } return(true); } } } return(false); }
public bool CreateRenderMovie(SFCamera camera, Type movieClassType) { #if !(UNITY_4_0 || UNITY_4_1) && UNITY_STANDALONE_WIN if (SystemInfo.graphicsDeviceVersion[0] == 'D') { return false; } #endif if (RenderTexture == null) { Debug.Log("RenderTexture is null, failure to create RenderMovie. Check if you specified all the parameters properly."); return false; } if (RTTMovie == null || RTTMovie.MovieID == 0) { if (camera) { Debug.Log("Creating movie"); SFMovieCreationParams creationParams = SFCamera.CreateRTTMovieCreationParams(SwfName, OriginX, OriginY, RenderTexture, ClearColor); creationParams.TheScaleModeType = ScaleModeType.SM_ExactFit; creationParams.IsInitFirstFrame = true; creationParams.IsAutoManageViewport = false; // Has the user specified a movie subclass? if (movieClassType != null) { SFManager sfMgr = camera.GetSFManager(); RTTMovie = Activator.CreateInstance(movieClassType, sfMgr, creationParams) as Movie; if (RTTMovie != null) { RTTMovie.SetRTT(this); } return true; } } } return false; }
/// <summary> /// Create and return a new movie instance with the given swfName. /// </summary> /// <returns> /// An instance of class T. /// </returns> /// <param name='camera'> /// 创建的Swf属于哪个SFCamera /// </param> /// <param name='swfName'> /// A path to the SWF or GFX file relative to the StreamingAssets folder. /// </param> /// <param name='fromByteStream'> /// If true, an attempt will be made to load this file into memory. On some platforms, this is useful when there isn't a real file path. /// </param> /// <param name='backgroundColor'> /// The background clear color for this movie. /// </param> /// <param name='renderTarget'> /// The RenderTarget to use when rendering this movie. A null value just renders to the screen. /// </param> /// <param name='scaleModeType'> /// Override the default ScaleModeType for this movie. Default is SM_ShowAll. /// </param> /// <typeparam name='T'> /// The class type that will be instanced for this movie. /// </typeparam> public static T CreateSwf <T>(SFCamera camera, string swfName, bool fromByteStream, Color32 backgroundColor, RenderTexture renderTarget = null, ScaleModeType scaleModeType = ScaleModeType.SM_ShowAll, string movieName = null) where T : Movie { if (camera == null) { return(default(T)); } int depth = 1; bool initFirstFrame = false; bool useBackgroundColor = false; bool autoManageViewport = true; int ox = 0, oy = 0, width = 0, height = 0; Int32 length = 0; IntPtr unmanagedData = IntPtr.Zero; Byte[] swfBytes = null; // load the swf either from a byte array or via path SFMovieCreationParams creationParams; if (renderTarget != null) { ox = 0; oy = 0; width = renderTarget.width; height = renderTarget.height; useBackgroundColor = true; autoManageViewport = false; } else { SFCamera.GetViewport(ref ox, ref oy, ref width, ref height); } bool loadSucceeded = false; if (fromByteStream) { swfBytes = LoadFileToMemory(swfName); if (swfBytes != null && swfBytes.Length > 0) { loadSucceeded = true; length = swfBytes.Length; unmanagedData = new IntPtr(); unmanagedData = Marshal.AllocCoTaskMem((int)length); Marshal.Copy(swfBytes, 0, unmanagedData, (int)length); } else { Debug.Log("Unable to load swf from memory!"); } } else { // no more to do here -- pass it on to the runtime. loadSucceeded = true; } string fullSwfPath = SFManager.GetScaleformContentPath() + swfName; creationParams = new SFMovieCreationParams(fullSwfPath, depth, ox, oy, width, height, unmanagedData, length, initFirstFrame, renderTarget, backgroundColor, useBackgroundColor, scaleModeType, autoManageViewport); if (movieName != null) { creationParams.MovieName = movieName; } if (loadSucceeded) { // create and return the instance GameObject uigo = new GameObject(Path.GetFileName(creationParams.MovieName)); uigo.transform.parent = SFGFxMovieManager.Instance.uigroup.transform; T instance = uigo.AddComponent <T>(); instance.Init(SFGFxMovieManager.Instance, camera.GetSFManager(), creationParams); //T instance = (T)Activator.CreateInstance(typeof(T), camera, camera.GetSFManager(), creationParams); return(instance); } else { Debug.Log(String.Format("Unable to load swf named: {0}", swfName)); return(default(T)); } }