コード例 #1
0
ファイル: SceneScript.cs プロジェクト: praveen1091/Beats2
        /// <summary>
        /// Called on during creation
        /// </summary>
        public virtual void Start()
        {
            // Add a background image
            Texture2D testBackground = Loader.LoadTexture(@"Z:\SkyDrive\Development\Workspace\trunk\beats2n\Assets\Resources\Common\Game\Background.jpg", false);

            background = BackgroundScript.Init(Display.centre, testBackground, Display.height);

            // Add an FPS counter
            UIFont uiFont = UITools.CreateFont(testFont, 30);

            fpsCounter = FpsCounterScript.Init(uiFont);
        }
コード例 #2
0
        /// <summary>
        /// Initialize a new GameObject
        /// </summary>
        public static BackgroundScript Init(GameObject parent, Texture2D texture, float height)
        {
            // Add game object
            GameObject gameObj = NGUITools.AddChild(parent);

            gameObj.name = "Background";

            // Add UITexture
            UITexture sprite = gameObj.AddComponent <UITexture>();

            // Add script
            BackgroundScript script = gameObj.AddComponent <BackgroundScript>();

            script.sprite       = sprite;
            script.targetHeight = height;
            script.texture      = texture;

            // Return reference to new script
            return(script);
        }