コード例 #1
0
            public Movie(SFManager sfmgr, SFMovieCreationParams creationParams)
            {
                if (sfmgr == null)
                {
                    MovieID = 0;
                    return;
                }

                MovieName             = creationParams.MovieName;
                ViewPort.OX           = creationParams.OX;
                ViewPort.OY           = creationParams.OY;
                ViewPort.Width        = creationParams.Width;
                ViewPort.Height       = creationParams.Height;
                pDataUnmanaged        = creationParams.pData;
                MovieID               = 0; // Assigned when the C++ Movie is created.
                MarkForRelease        = false;
                SFMgr                 = sfmgr;
                IsFocused             = false;
                AdvanceWhenGamePaused = false;
                IsAutoManageViewport  = creationParams.IsAutoManageViewport;
                TheScaleModeType      = creationParams.TheScaleModeType;

                int cpSize = Marshal.SizeOf(typeof(SFMovieCreationParams));

                IntPtr pdata = Marshal.AllocCoTaskMem(cpSize);

                Marshal.StructureToPtr(creationParams, pdata, false);

                MovieID = SF_CreateMovie(pdata);
                Marshal.DestroyStructure(pdata, typeof(SFMovieCreationParams));
                if (MovieID != -1)
                {
                    SFMgr.AddMovie(this);
                }
            }
コード例 #2
0
 public SFMovieCreationParams(String name, int ox, int oy, int width, int height,
                              IntPtr pdata, int length, bool initFirstFrame, Color32 bgColor, bool useBackgroundColor = false,
                              ScaleModeType scaleModeType = ScaleModeType.SM_ShowAll, bool bautoManageVP = true)
 {
     MovieName            = name;
     OX                   = ox;
     OY                   = oy;
     Width                = width;
     Height               = height;
     IsInitFirstFrame     = initFirstFrame;
     IsAutoManageViewport = bautoManageVP;
     pData                = pdata;
     Length               = length;
     TheScaleModeType     = scaleModeType;
     IsUseBackgroundColor = useBackgroundColor;
     IsRenderToTexture    = false;
     TextureId            = 0;
     TexWidth             = 0;
     TexHeight            = 0;
     Red                  = bgColor.r;
     Green                = bgColor.g;
     Blue                 = bgColor.b;
     Alpha                = bgColor.a;
     IsMemoryFile         = (pdata != IntPtr.Zero);
     Sentinal             = SFSentinal.Sentinal;
     IsPad0               = IsPad1 = IsPad2 = false;
 }
コード例 #3
0
// Allows a rendertexture to be passed in
    public SFMovieCreationParams(String name, int ox, int oy, int width, int height,
        IntPtr pdata, int length, bool initFirstFrame, RenderTexture texture, Color32 bgColor, 
		bool useBackgroundColor = false, ScaleModeType scaleModeType = ScaleModeType.SM_ShowAll, bool bAutoManageVP = true):
       this(name, ox, oy, width, height, pdata, length, initFirstFrame, bgColor, useBackgroundColor, scaleModeType, bAutoManageVP)
	   {
        IsRenderToTexture    = (texture != null);
        TexWidth            = ((texture != null) ? (UInt32)texture.width : 0);
        TexHeight           = ((texture != null) ? (UInt32)texture.height : 0);

#if (UNITY_4_0) || (UNITY_4_1)
        if (texture)
        {
#if UNITY_IPHONE
            TextureId = (uint)texture.GetNativeTextureID();
#else
            IntPtr texPtr = texture.GetNativeTexturePtr();
            TextureId = (uint)(texPtr);
#endif //UNITY_IPHONE
        }
        else
        {
            TextureId = 0;
        }
#else
        TextureId = ((texture != null) ? (UInt32)texture.GetNativeTextureID() : 0);
#if UNITY_STANDALONE_WIN
        if (SystemInfo.graphicsDeviceVersion[0] == 'D')
        {
            // SystemInfo.graphicsDeviceVersion starts with either "Direct3D" or "OpenGL".
            // We need to disable RTT on D3D+Windows because GetNativeTextureID() returns 
            // a garbage value in D3D mode instead of zero, even though 
            // GetNativeTextureID() is only supported in OpenGL mode.
            TextureId = 0;
            IsRenderToTexture = false;
            TexWidth = 0;
            TexHeight = 0;
        }
#endif //UNITY_STANDALONE_WIN
#endif //(UNITY_4_0) || (UNITY_4_1)

    //  pData = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(System.IntPtr)));
    //  Marshal.WriteIntPtr(pData, pdata);
    }
コード例 #4
0
// Allows a rendertexture to be passed in
        public SFMovieCreationParams(String name, int ox, int oy, int width, int height,
                                     IntPtr pdata, int length, bool initFirstFrame, RenderTexture texture, Color32 bgColor,
                                     bool useBackgroundColor = false, ScaleModeType scaleModeType = ScaleModeType.SM_ShowAll, bool bAutoManageVP = true) :
            this(name, ox, oy, width, height, pdata, length, initFirstFrame, bgColor, useBackgroundColor, scaleModeType, bAutoManageVP)
        {
            IsRenderToTexture = (texture != null);
            TexWidth          = ((texture != null) ? (UInt32)texture.width : 0);
            TexHeight         = ((texture != null) ? (UInt32)texture.height : 0);

#if (UNITY_4_0) || (UNITY_4_1)
            if (texture)
            {
#if UNITY_IPHONE
                TextureId = (uint)texture.GetNativeTextureID();
#else
                IntPtr texPtr = texture.GetNativeTexturePtr();
                TextureId = (uint)(texPtr);
#endif //UNITY_IPHONE
            }
            else
            {
                TextureId = 0;
            }
#else
            TextureId = ((texture != null) ? (UInt32)texture.GetNativeTextureID() : 0);
#if UNITY_STANDALONE_WIN
            if (SystemInfo.graphicsDeviceVersion[0] == 'D')
            {
                // SystemInfo.graphicsDeviceVersion starts with either "Direct3D" or "OpenGL".
                // We need to disable RTT on D3D+Windows because GetNativeTextureID() returns
                // a garbage value in D3D mode instead of zero, even though
                // GetNativeTextureID() is only supported in OpenGL mode.
                TextureId         = 0;
                IsRenderToTexture = false;
                TexWidth          = 0;
                TexHeight         = 0;
            }
#endif //UNITY_STANDALONE_WIN
#endif //(UNITY_4_0) || (UNITY_4_1)

            //  pData = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(System.IntPtr)));
            //  Marshal.WriteIntPtr(pData, pdata);
        }
コード例 #5
0
            public Movie(SFManager sfmgr, SFMovieCreationParams creationParams)
            {
                if (sfmgr == null)
                {
                MovieID = 0;
                return;
                }

                MovieName                   = creationParams.MovieName;
                ViewPort.OX                 = creationParams.OX;
                ViewPort.OY                 = creationParams.OY;
                ViewPort.Width              = creationParams.Width;
                ViewPort.Height             = creationParams.Height;
                pDataUnmanaged				= creationParams.pData;
                MovieID                     = 0; // Assigned when the C++ Movie is created.
                MarkForRelease              = false;
                SFMgr                       = sfmgr;
                IsFocused                  	= false;
                AdvanceWhenGamePaused      	= false;
                IsAutoManageViewport        = creationParams.IsAutoManageViewport;
                TheScaleModeType			= creationParams.TheScaleModeType;

                int cpSize = Marshal.SizeOf(typeof(SFMovieCreationParams));

                IntPtr pdata = Marshal.AllocCoTaskMem(cpSize);
                Marshal.StructureToPtr(creationParams, pdata, false);

                MovieID = SF_CreateMovie(pdata);
                Marshal.DestroyStructure(pdata, typeof(SFMovieCreationParams));
                if (MovieID != -1)
                {
                SFMgr.AddMovie(this);
                }
            }
コード例 #6
0
    public SFMovieCreationParams(String name, int ox, int oy, int width, int height,
        IntPtr pdata, int length, bool initFirstFrame, Color32 bgColor, bool useBackgroundColor = false,
        ScaleModeType scaleModeType = ScaleModeType.SM_ShowAll, bool bautoManageVP = true)
    {
		MovieName = name;
		OX = ox;
		OY = oy;
		Width = width;
		Height = height;
		IsInitFirstFrame = initFirstFrame;
		IsAutoManageViewport = bautoManageVP;
		pData = pdata;
		Length = length;
		TheScaleModeType = scaleModeType;
		IsUseBackgroundColor = useBackgroundColor;
		IsRenderToTexture = false;
		TextureId = 0;
		TexWidth = 0;
		TexHeight = 0;
		Red = bgColor.r;
		Green = bgColor.g;
		Blue = bgColor.b;
		Alpha = bgColor.a;
		IsMemoryFile = (pdata != IntPtr.Zero);
		Sentinal = SFSentinal.Sentinal;
		IsPad0 = IsPad1 = IsPad2 = false;
    }
コード例 #7
0
ファイル: SFGFxMovieManager.cs プロジェクト: zwong91/Titan
    /// <summary>
    /// 创建一个Window
    /// </summary>
    /// <typeparam name="T">创建的是那个类</typeparam>
    /// <param name="_name">swf名字,用于区分各个不同的swf</param>
    /// <param name="_fullPatch">全路径,相对于streamingasset文件夹</param>
    /// <param name="_backgroundColor">背景颜色(255为单位)</param>
    /// <param name="_bVisibleOnCreate">是否创建的时候在画布上显示出来</param>
    /// <param name="_bIgnoreMovie">是否加入忽略列表,目前用于按esc隐藏界面功能</param>
    /// <param name="_modeType">movie的缩放方式</param>
    /// <param name="_fromByteStream">从字节流中创建</param>
    /// <param name="_renderTexture">是否使用Rt</param>
    /// <param name="_scaleModeType">缩放模式</param>
    /// <param name="_movieName">电影名称,暂时忽略</param>
    /// <returns></returns>
    public T CreateWindow <T>(string _name, string _fullPatch, Color32 _backgroundColor, bool _bVisibleOnCreate = false, ScaleModeType _modeType = ScaleModeType.SM_ShowAll, bool _fromByteStream = true, RenderTexture _renderTexture = null, string _movieName = null) where T : Movie
    {
        if (GetWindow(_name) != null)
        {
            return(GetWindow(_name) as T);
        }

        T newMovie = default(T);


        newMovie = GfxUtil.CreateSwf <T>(this, _fullPatch, _fromByteStream, _backgroundColor, _renderTexture, _modeType, _movieName);

        if (null == newMovie)
        {
            return(null);
        }

        SFMovieEx MovieEx = newMovie as SFMovieEx;

        MovieEx.IsVisibleOnCreate = _bVisibleOnCreate;

        windowRegistryList.Add(_name, newMovie);
        return(newMovie);
    }
コード例 #8
0
ファイル: GfxUtil.cs プロジェクト: zwong91/Titan
    /// <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));
        }
    }
コード例 #9
0
ファイル: SFMovie.cs プロジェクト: NGonGames/GlobalGamJam2014
            /// <summary>
            /// Movie constructor, moviedef is created automatically. 
            /// </summary>
            /// <param name="sfmgr">Scaleform manager.</param>
            /// <param name="creationParams">Movie creation parameters.</param>
            public Movie(SFManager sfmgr, SFMovieCreationParams creationParams)
            {
                if(sfmgr == null)
                {
                MovieID = 0;
                return;
                }

                //1. Set parameters like name and viewport
                MovieName               = creationParams.MovieName;
                ViewPort.OX             = creationParams.OX;
                ViewPort.OY             = creationParams.OY;
                ViewPort.Width          = creationParams.Width;
                ViewPort.Height         = creationParams.Height;
                pDataUnmanaged			= creationParams.pData;
                Depth					= creationParams.Depth; // Rendering order. Movie with Depth + 1 will render on top of Movie with Depth
                MovieID                 = 0; // Assigned when the C++ Movie is created.
                MarkForRelease          = false;
                SFMgr                   = sfmgr;
                IsFocused               = false;
                AdvanceWhenGamePaused   = false;
                IsAutoManageViewport    = creationParams.IsAutoManageViewport;
                TheScaleModeType		= creationParams.TheScaleModeType;

                int cpSize = Marshal.SizeOf(typeof(SFMovieCreationParams));
                IntPtr pCreationParams = Marshal.AllocCoTaskMem(cpSize);
                Marshal.StructureToPtr(creationParams, pCreationParams, false);
                MovieID = SF_CreateMovie(pCreationParams);

                if(MovieID == 0)
                {
                return;
                }

                //3. Add into SFManager
                SFMgr.AddMovie(this);
            }