private void Init() { if (m_keepAlive) { DontDestroyOnLoad(transform.root.gameObject); } m_fpsMonitor = GetComponentInChildren(typeof(FpsMonitor), true) as FpsMonitor; m_ramMonitor = GetComponentInChildren(typeof(RamMonitor), true) as RamMonitor; m_audioMonitor = GetComponentInChildren(typeof(AudioMonitor), true) as AudioMonitor; m_fpsManager = GetComponentInChildren(typeof(FpsManager), true) as FpsManager; m_ramManager = GetComponentInChildren(typeof(RamManager), true) as RamManager; m_audioManager = GetComponentInChildren(typeof(AudioManager), true) as AudioManager; m_advancedData = GetComponentInChildren(typeof(AdvancedData), true) as AdvancedData; m_fpsManager.SetPosition(m_graphModulePosition); m_ramManager.SetPosition(m_graphModulePosition); m_audioManager.SetPosition(m_graphModulePosition); m_advancedData.SetPosition(m_advancedModulePosition); m_fpsManager.SetState(m_fpsModuleState); m_ramManager.SetState(m_ramModuleState); m_audioManager.SetState(m_audioModuleState); m_advancedData.SetState(m_advancedModuleState); }
// Use this for initialization void Start() { fpsMonitor = GetComponent <FpsMonitor> (); webCamTextureToMatHelper = gameObject.GetComponent <MLCameraPreviewToMatHelper> (); // int width, height; // Dimensions (requestedResolution, out width, out height); // webCamTextureToMatHelper.requestedWidth = width; // webCamTextureToMatHelper.requestedHeight = height; // webCamTextureToMatHelper.requestedFPS = (int)requestedFPS; webCamTextureToMatHelper.Initialize(); // Update GUI state requestedResolutionDropdown.value = (int)requestedResolution; string[] enumNames = System.Enum.GetNames(typeof(FPSPreset)); int index = Array.IndexOf(enumNames, requestedFPS.ToString()); requestedFPSDropdown.value = index; rotate90DegreeToggle.isOn = webCamTextureToMatHelper.rotate90Degree; flipVerticalToggle.isOn = webCamTextureToMatHelper.flipVertical; flipHorizontalToggle.isOn = webCamTextureToMatHelper.flipHorizontal; cascade = new CascadeClassifier(); cascade.load(Utils.getFilePath("lbpcascade_frontalface.xml")); // cascade.load (Utils.getFilePath ("haarcascade_frontalface_alt.xml")); if (cascade.empty()) { Debug.LogError("cascade file is not loaded. Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. "); } }
protected override void Draw(GameTime gameTime) { FpsMonitor.Update(); GraphicsDevice.RasterizerState = RasterizerState.CullClockwise; GameStateManager.Draw(gameTime); GuiManager.Draw(gameTime); }
public Alex(LaunchSettings launchSettings) { Instance = this; LaunchSettings = launchSettings; DeviceManager = new GraphicsDeviceManager(this) { PreferMultiSampling = false, SynchronizeWithVerticalRetrace = false, GraphicsProfile = GraphicsProfile.Reach, }; Content.RootDirectory = "assets"; IsFixedTimeStep = false; // graphics.ToggleFullScreen(); this.Window.AllowUserResizing = true; this.Window.ClientSizeChanged += (sender, args) => { if (DeviceManager.PreferredBackBufferWidth != Window.ClientBounds.Width || DeviceManager.PreferredBackBufferHeight != Window.ClientBounds.Height) { if (DeviceManager.IsFullScreen) { DeviceManager.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; DeviceManager.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; } else { DeviceManager.PreferredBackBufferWidth = Window.ClientBounds.Width; DeviceManager.PreferredBackBufferHeight = Window.ClientBounds.Height; } DeviceManager.ApplyChanges(); //CefWindow.Size = new System.Drawing.Size(Window.ClientBounds.Width, Window.ClientBounds.Height); } }; JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { Converters = new List <JsonConverter>() { new Texture2DJsonConverter(GraphicsDevice) }, Formatting = Formatting.Indented }; UIThreadQueue = new ConcurrentQueue <Action>(); PluginManager = new PluginManager(this); FpsMonitor = new FpsMonitor(); }
protected override void LoadContent() { bannerManager = new BannerManager(Content, GraphicsDevice); animationManager = new AnimationManager(Content); tileManager = new TileManager(Content, bannerManager); networkingManager = new NetworkingManager(bannerManager, tileManager, animationManager, Content.Load <SpriteFont>(@"Fonts\font")); fpsMonitor = new FpsMonitor(Content.Load <SpriteFont>(@"Fonts\font"), new Vector2(10, 10)); menuManager = new MenuManager(Content, bannerManager, networkingManager); screenshotManager = new ScreenshotManager(GraphicsDevice, Content.Load <SpriteFont>(@"Fonts\font")); spriteBatch = new SpriteBatch(GraphicsDevice); }
protected override void Draw(GameTime gameTime) { //GraphicsDevice.Present(); FpsMonitor.Update(); GraphicsDevice.RasterizerState = RasterizerState.CullClockwise; GameStateManager.Draw(gameTime); GuiManager.Draw(gameTime); this.Metrics = GraphicsDevice.Metrics; }
void Start() { Input.backButtonLeavesApp = true; _fpsMonitor = GetComponent <FpsMonitor>(); _webCamTextureToMatHelper = GetComponent <WebCamTextureToMatHelper>(); _webCamTextureToMatHelper.Initialize(); _fire = Instantiate(_firePrefab, new Vector3(0f, 0f, FIRE_Z_POS), Quaternion.identity); _fire.transform.localScale = new Vector3(FIRE_SCALE, FIRE_SCALE, FIRE_SCALE); }
protected override void OnDraw(IRenderArgs args) { if (!_backgroundSkyBox.Loaded) { _backgroundSkyBox.Load(Alex.GuiRenderer); } _backgroundSkyBox.Draw(args); base.OnDraw(args); FpsMonitor.Update(); }
// Use this for initialization void Start() { fpsMonitor = GetComponent <FpsMonitor>(); imageOptimizationHelper = gameObject.GetComponent <ImageOptimizationHelper>(); webCamTextureToMatHelper = gameObject.GetComponent <MLCameraPreviewToMatHelper>(); classes_filepath = Utils.getFilePath("dnn/" + classes); config_filepath = Utils.getFilePath("dnn/" + config); model_filepath = Utils.getFilePath("dnn/" + model); Run(); }
public DiagnosticsScene(GraphicsDevice graphicsDevice, ContentManager content) { fpsMonitor = new FpsMonitor(); this.graphicsDevice = graphicsDevice; font = content.Load <SpriteFont>(@"Fonts/diagnosticsFont"); this.background = content.Load <Texture2D>(@"Textures/whiteRectangle"); texts = new Dictionary <Vector2, string>(); LargestWidth = 0; LargestHeight = 0; bgTransparency = new SmoothTransition(0.5f, 0.002f, 0.0f, 0.5f); fontTransparency = new SmoothTransition(1.0f, 0.004f, 0.0f, 1.0f); isActive = true; }
void Start() { fpsMonitor = GetComponent <FpsMonitor>(); webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper>(); #if UNITY_ANDROID && !UNITY_EDITOR // Avoids the front camera low light issue that occurs in only some Android devices (e.g. Google Pixel, Pixel2). webCamTextureToMatHelper.avoidAndroidFrontCameraLowLightIssue = true; #endif webCamTextureToMatHelper.Initialize(); m_MyAudioSource = GetComponent <AudioSource>(); }
protected override void LoadContent() { // Create a sprite batch to draw those textures spriteBatch = new SpriteBatch(graphics.GraphicsDevice); Skins(); //default skint skin = skin1; difficulty = Difficulty.Easy; //InitiateLoad(); mapTexture = skin.mapTexture; //check if images exists; try { mapTexture = skin.mapTexture; mapGradTexture = Content.Load <Texture2D>("image\\mapgrad"); //fonts fontArial10 = Content.Load <SpriteFont>("fonts\\Arial10"); } catch { MyExit(); } if (mapTexture == null || mapGradTexture == null || fontArial10 == null) { MyExit(); } mapGradTextureData = new Color[mapGradTexture.Width * mapGradTexture.Height]; mapGradTexture.GetData(mapGradTextureData); // Get the bounding rectangle of this block mapRectangle = new Rectangle(0, 0, skin.mapTexture.Width, skin.mapTexture.Height); finishMapRectangle = new Rectangle(457, 335, 1, 130); //Creating and adding checkpointto list CheckPoints(); winner = new StringBuilder(); //fps counter fpsMonitor = new FpsMonitor(); keyUup = false; keyYup = false; keyIup = false; keyKup = false; }
public OpenGLWindow(int width, int height) : base(width, height, GraphicsMode.Default, "Title", GameWindowFlags.FixedWindow, DisplayDevice.Default, 4, 0, OpenTK.Graphics.GraphicsContextFlags.ForwardCompatible) { #region GL_VERSION //this will return your version of opengl int major, minor; GL.GetInteger(GetPName.MajorVersion, out major); GL.GetInteger(GetPName.MinorVersion, out minor); logger.Info("Creating OpenGL version {2}.{3} window with size {0} x {1}", width, height, major, minor); #endregion Input.Initialize(this); // Move to ? fpsm = new FpsMonitor(); camera = new Camera(new Vector3(0.0f, 2.0f, 6.0f), new Quaternion(0, 0, 0), Width, Height); }
// Use this for initialization void Start() { fpsMonitor = GetComponent <FpsMonitor>(); imageOptimizationHelper = gameObject.GetComponent <ImageOptimizationHelper>(); webCamTextureToMatHelper = gameObject.GetComponent <MLCameraPreviewToMatHelper>(); webCamTextureToMatHelper.Initialize(); cascade = new CascadeClassifier(); //cascade.load (Utils.getFilePath ("lbpcascade_frontalface.xml")); cascade.load(Utils.getFilePath("haarcascade_frontalface_alt.xml")); if (cascade.empty()) { Debug.LogError("cascade file is not loaded. Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. "); } }
//HololensVideoWriterAsPlugin recorder; // Use this for initialization protected override void Start() { fpsMonitor = GetComponent <FpsMonitor>(); base.Start(); webCamTextureToMatHelper = gameObject.GetComponent <HololensCameraStreamToMatHelper>(); #if NETFX_CORE && !DISABLE_HOLOLENSCAMSTREAM_API webCamTextureToMatHelper.frameMatAcquired += OnFrameMatAcquired; #endif webCamTextureToMatHelper.Initialize(); cameraInstance = GameObject.FindWithTag("MainCamera").GetComponent <Camera>(); //29n //recorder = gameObject.GetComponent<HololensVideoWriterAsPlugin>(); }
public PlayState(DemoGame game, string LevelFile) : base(game) { spriteBatch = game.Services.GetService <SpriteBatch>(); camera = game.Services.GetService <FocusCamera>(); settings = game.Services.GetService <GameSettings>(); scriptingEngine = game.Services.GetService <ScriptingEngine>(); context = game.Services.GetService <GameContext>(); monitor = new FpsMonitor(); lvlFile = LevelFile; //var dir = Path.Combine(DemoGame.ContentManager.RootDirectory,"Scripts"); //var files = Directory.GetFiles(dir); //scriptingEngine.LoadScript(files); hud = new HeadsUpDisplay(); LoadContent(game.ContentManager); Initialize(); }
void Start() { Input.backButtonLeavesApp = true; Screen.sleepTimeout = SleepTimeout.NeverSleep; _toMatHelper = GetComponent <WebCamTextureToMatHelper>(); _invCvtr = new InvisibleConverter(_text); _cameraSwitcher = new CameraSwitcher(_toMatHelper, _invCvtr, _mainCanvas, _camSwitchDialog); _fpsMonitor = GetComponent <FpsMonitor>(); _recordSound = GetComponent <AudioSource>(); //リア/フロントをPlayerPrefabsから読み込む _toMatHelper.requestedIsFrontFacing = _cameraSwitcher.UseCamera; _toMatHelperMgr = new ToMatHelperManager(gameObject, _toMatHelper, _fpsMonitor); _toMatHelper.Initialize(); //スマホの場合カメラ起動まで指定秒待つ #if !UNITY_EDITOR && UNITY_ANDROID Task.Run(WaitCamStartup).Wait(); #endif }
void Start() { m_fpsMonitor = GetComponentInChildren <FpsMonitor>(); m_ramMonitor = GetComponentInChildren <RamMonitor>(); m_audioMonitor = GetComponentInChildren <AudioMonitor>(); }
void Start() { _toMatHelper = GetComponent <WebCamTextureToMatHelper>(); _fpsMonitor = GetComponent <FpsMonitor>(); }
public Alex(LaunchSettings launchSettings) { Instance = this; LaunchSettings = launchSettings; OperatingSystem = $"{System.Runtime.InteropServices.RuntimeInformation.OSDescription} ({System.Runtime.InteropServices.RuntimeInformation.OSArchitecture})"; DeviceManager = new GraphicsDeviceManager(this) { PreferMultiSampling = false, SynchronizeWithVerticalRetrace = false, GraphicsProfile = GraphicsProfile.Reach, }; DeviceManager.PreparingDeviceSettings += (sender, args) => { Gpu = args.GraphicsDeviceInformation.Adapter.Description; args.GraphicsDeviceInformation.PresentationParameters.DepthStencilFormat = DepthFormat.Depth24Stencil8; DeviceManager.PreferMultiSampling = true; }; Content = new StreamingContentManager(base.Services, "assets"); // Content.RootDirectory = "assets"; IsFixedTimeStep = false; // graphics.ToggleFullScreen(); this.Window.AllowUserResizing = true; this.Window.ClientSizeChanged += (sender, args) => { if (DeviceManager.PreferredBackBufferWidth != Window.ClientBounds.Width || DeviceManager.PreferredBackBufferHeight != Window.ClientBounds.Height) { if (DeviceManager.IsFullScreen) { DeviceManager.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; DeviceManager.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; } else { DeviceManager.PreferredBackBufferWidth = Window.ClientBounds.Width; DeviceManager.PreferredBackBufferHeight = Window.ClientBounds.Height; } DeviceManager.ApplyChanges(); //CefWindow.Size = new System.Drawing.Size(Window.ClientBounds.Width, Window.ClientBounds.Height); } }; JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { Converters = new List <JsonConverter>() { new Texture2DJsonConverter(GraphicsDevice) }, Formatting = Formatting.Indented }; IServiceCollection serviceCollection = new ServiceCollection(); ConfigureServices(serviceCollection); Services = serviceCollection.BuildServiceProvider(); UIThreadQueue = new ConcurrentQueue <Action>(); PluginManager = new PluginManager(Services); FpsMonitor = new FpsMonitor(); Resources = Services.GetRequiredService <ResourceManager>(); ThreadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount, ThreadType.Background, "Dedicated ThreadPool")); PacketFactory.CustomPacketFactory = new AlexPacketFactory(); KeyboardInputListener.InstanceCreated += KeyboardInputCreated; }
// Use this for initialization void Start() { fpsMonitor = GetComponent <FpsMonitor> (); Initialize(); }
public Alex(LaunchSettings launchSettings) { EntityProperty.Factory = new AlexPropertyFactory(); /*MiNET.Utils.DedicatedThreadPool fastThreadPool = * ReflectionHelper.GetPrivateStaticPropertyValue<MiNET.Utils.DedicatedThreadPool>( * typeof(MiNetServer), "FastThreadPool"); * * fastThreadPool?.Dispose(); * fastThreadPool?.WaitForThreadsExit(); * * ReflectionHelper.SetPrivateStaticPropertyValue<MiNET.Utils.DedicatedThreadPool>( * typeof(MiNetServer), "FastThreadPool", * new MiNET.Utils.DedicatedThreadPool( * new MiNET.Utils.DedicatedThreadPoolSettings(8, "MiNETServer Fast")));*/ ThreadPool.GetMaxThreads(out _, out var completionPortThreads); //ThreadPool.SetMaxThreads(Environment.ProcessorCount, completionPortThreads); Instance = this; LaunchSettings = launchSettings; OperatingSystem = $"{System.Runtime.InteropServices.RuntimeInformation.OSDescription} ({System.Runtime.InteropServices.RuntimeInformation.OSArchitecture})"; DeviceManager = new GraphicsDeviceManager(this) { PreferMultiSampling = false, SynchronizeWithVerticalRetrace = false, GraphicsProfile = GraphicsProfile.Reach, }; DeviceManager.PreparingDeviceSettings += (sender, args) => { Gpu = args.GraphicsDeviceInformation.Adapter.Description; args.GraphicsDeviceInformation.PresentationParameters.DepthStencilFormat = DepthFormat.Depth24Stencil8; DeviceManager.PreferMultiSampling = true; }; Content = new StreamingContentManager(base.Services, "assets"); // Content.RootDirectory = "assets"; IsFixedTimeStep = false; // graphics.ToggleFullScreen(); this.Window.AllowUserResizing = true; this.Window.ClientSizeChanged += (sender, args) => { if (DeviceManager.PreferredBackBufferWidth != Window.ClientBounds.Width || DeviceManager.PreferredBackBufferHeight != Window.ClientBounds.Height) { if (DeviceManager.IsFullScreen) { DeviceManager.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; DeviceManager.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; } else { DeviceManager.PreferredBackBufferWidth = Window.ClientBounds.Width; DeviceManager.PreferredBackBufferHeight = Window.ClientBounds.Height; } DeviceManager.ApplyChanges(); //CefWindow.Size = new System.Drawing.Size(Window.ClientBounds.Width, Window.ClientBounds.Height); } }; JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { Converters = new List <JsonConverter>() { new Texture2DJsonConverter(GraphicsDevice) }, Formatting = Formatting.Indented }; ServerTypeManager = new ServerTypeManager(); PluginManager = new PluginManager(); Storage = new StorageSystem(LaunchSettings.WorkDir); Options = new OptionsProvider(Storage); IServiceCollection serviceCollection = new ServiceCollection(); serviceCollection.AddSingleton <Alex>(this); serviceCollection.AddSingleton <ContentManager>(Content); serviceCollection.AddSingleton <IStorageSystem>(Storage); serviceCollection.AddSingleton <IOptionsProvider>(Options); InitiatePluginSystem(serviceCollection); AudioEngine = new AudioEngine(Storage); ConfigureServices(serviceCollection); Services = serviceCollection.BuildServiceProvider(); PluginManager.Setup(Services); PluginManager.LoadPlugins(); ServerTypeManager.TryRegister("java", new JavaServerType(this)); ServerTypeManager.TryRegister( "bedrock", new BedrockServerType(this, Services.GetService <XboxAuthService>())); UIThreadQueue = new ConcurrentQueue <Action>(); FpsMonitor = new FpsMonitor(); Resources = Services.GetRequiredService <ResourceManager>(); // ThreadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount, // ThreadType.Background, "Dedicated ThreadPool")); KeyboardInputListener.InstanceCreated += KeyboardInputCreated; TextureUtils.RenderThread = Thread.CurrentThread; TextureUtils.QueueOnRenderThread = action => UIThreadQueue.Enqueue(action); }
public ToMatHelperManager(GameObject quad, WebCamTextureToMatHelper texToMatHelper, FpsMonitor fpsMonitor) { _quad = quad; _texToMatHelper = texToMatHelper; _fpsMonitor = fpsMonitor; }
public TitleState() { FpsMonitor = new FpsMonitor(); _backgroundSkyBox = new GuiPanoramaSkyBox(Alex); Background.Texture = _backgroundSkyBox; Background.RepeatMode = TextureRepeatMode.Stretch; #region Create MainMenu _mainMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f) }; _mainMenu.AddMenuItem("Multiplayer", JavaEditionButtonPressed, EnableMultiplayer); _mainMenu.AddMenuItem("SinglePlayer", OnSinglePlayerPressed); _mainMenu.AddMenuItem("Options", () => { Alex.GameStateManager.SetActiveState("options"); }); _mainMenu.AddMenuItem("Exit", () => { Alex.Exit(); }); #endregion #region Create DebugMenu _debugMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f), }; _debugMenu.AddMenuItem("Debug Blockstates", DebugWorldButtonActivated); _debugMenu.AddMenuItem("Debug Flatland", DebugFlatland); //_debugMenu.AddMenuItem("Debug Anvil", DebugAnvil); _debugMenu.AddMenuItem("Debug Chunk", DebugChunkButtonActivated); // _debugMenu.AddMenuItem("Debug XBL Login", BedrockEditionButtonPressed); _debugMenu.AddMenuItem("Go Back", DebugGoBackPressed); #endregion #region Create SPMenu _spMenu = new GuiStackMenu() { Margin = new Thickness(15, 0, 15, 0), Padding = new Thickness(0, 50, 0, 0), Width = 125, Anchor = Alignment.FillY | Alignment.MinX, ChildAnchor = Alignment.CenterY | Alignment.FillX, BackgroundOverlay = new Color(Color.Black, 0.35f), }; _spMenu.AddMenuItem("SinglePlayer", () => {}, false); _spMenu.AddMenuItem("Debug Worlds", OnDebugPressed); _spMenu.AddMenuItem("Return to main menu", SpBackPressed); #endregion CreateProtocolMenu(); AddChild(_mainMenu); AddChild(_logo = new GuiImage(GuiTextures.AlexLogo) { Margin = new Thickness(95, 25, 0, 0), Anchor = Alignment.TopCenter }); AddChild(_splashText = new GuiTextElement() { TextColor = TextColor.Yellow, Rotation = 17.5f, Margin = new Thickness(240, 15, 0, 0), Anchor = Alignment.TopCenter, Text = "Who liek minecwaf?!", }); _debugInfo = new GuiDebugInfo(); _debugInfo.AddDebugRight(() => $"GPU Memory: {API.Extensions.GetBytesReadable(GpuResourceManager.GetMemoryUsage)}"); _debugInfo.AddDebugLeft(() => $"FPS: {FpsMonitor.Value:F0}"); _playerProfileService = Alex.Services.GetService <IPlayerProfileService>(); _playerProfileService.ProfileChanged += PlayerProfileServiceOnProfileChanged; Alex.GameStateManager.AddState("options", new OptionsState(_backgroundSkyBox)); }