Ejemplo n.º 1
0
        private IEnumerator LoadMenuAndUiAsync(float delayLoadingTime)
        {
            yield return(new WaitForSeconds(delayLoadingTime));

            yield return(SceneManager.LoadSceneAsync("Menu"));

            yield return(SceneManager.LoadSceneAsync("Ui", LoadSceneMode.Additive));

            OnSceneChanged?.Invoke(true);
        }
Ejemplo n.º 2
0
        IEnumerator LoadingUIMenu(float delayTime)
        {
            yield return(new WaitForSeconds(delayTime));

            yield return(SceneManager.LoadSceneAsync("Menu"));

            yield return(SceneManager.LoadSceneAsync("UI", LoadSceneMode.Additive));

            OnSceneChanged?.Invoke(true);
        }
Ejemplo n.º 3
0
        private IEnumerator LoadLevel1Async()
        {
            yield return(new WaitForSeconds(delayLevelTime));

            int buildIndex = SceneManager.GetActiveScene().buildIndex;

            yield return(SceneManager.UnloadSceneAsync(buildIndex));

            SceneManager.LoadSceneAsync(buildIndex, LoadSceneMode.Additive).completed +=
                (AsyncOperation obj) => { SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(buildIndex)); };

            OnSceneChanged?.Invoke(false);
        }
Ejemplo n.º 4
0
        public void LoadScene(Scenes s)
        {
            if (s != Scenes.none)
            {
                var old = scene;

                SM.SceneManager.LoadScene(s.ToString());

                if (OnSceneChanged != null)
                {
                    OnSceneChanged.Invoke(s, old);
                }
            }
            else
            {
                Debug.LogError("Uknown scene " + s + "!");
            }
        }
Ejemplo n.º 5
0
        private IEnumerator SplashScreenAsync(SceneTypeEnum sceneType)
        {
            yield return(SceneManager.LoadSceneAsync(SceneTypeEnum.SplashScreen.ToString(), LoadSceneMode.Additive));

            OnSceneChanged?.Invoke(SceneTypeEnum.SplashScreen);

            yield return(SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene()));

            SceneManager.SetActiveScene(SceneManager.GetSceneByName("SplashScreen"));

            yield return(new WaitForSeconds(3f));

            yield return(SceneManager.UnloadSceneAsync(SceneManager.GetActiveScene()));

            yield return(SceneManager.LoadSceneAsync(sceneType.ToString(), LoadSceneMode.Additive));

            OnSceneChanged.Invoke(sceneType);

            SceneManager.SetActiveScene(SceneManager.GetSceneByName(sceneType.ToString()));
        }
Ejemplo n.º 6
0
        public void LoadScene(string name)
        {
            Scenes newScene = Scenes.none;

            Enum.TryParse(name, out newScene);

            if (newScene != Scenes.none)
            {
                var old = scene;

                SM.SceneManager.LoadScene(name);

                if (OnSceneChanged != null)
                {
                    OnSceneChanged.Invoke(newScene, old);
                }
            }
            else
            {
                Debug.LogError("Uknown scene " + name + "!");
            }
        }
Ejemplo n.º 7
0
 private void Start()
 {
     sceneChanged?.Invoke();
 }
Ejemplo n.º 8
0
 public void TriggerOnSceneChanged(Node newScene)
 {
     OnSceneChanged?.Invoke(newScene);
 }
    public IEnumerator ReturnMenuAsync()
    {
        OnSceneChanged?.Invoke();

        yield return(SceneManager.LoadSceneAsync("Menu"));
    }
    private IEnumerator StartGameAsync()
    {
        OnSceneChanged?.Invoke();

        yield return(SceneManager.LoadSceneAsync("Game"));
    }
Ejemplo n.º 11
0
            private readonly AnimationCB m_animation_cb;                    // A local reference to prevent the callback being garbage collected

            public Window(View3d view, HWND hwnd, bool?gdi_compatible_backbuffer = null, int?multi_sampling = null, string?dbg_name = null)
            {
                View   = view;
                Hwnd   = hwnd;
                Diag   = new Diagnostics(this);
                m_opts = new WindowOptions
                {
                    ErrorCB    = HandleError,
                    ErrorCBCtx = IntPtr.Zero,
                    GdiCompatibleBackBuffer = gdi_compatible_backbuffer ?? false,
                    Multisampling           = multi_sampling ?? 4,
                    DbgName = dbg_name ?? string.Empty,
                };

                // Create the window
                Handle = View3D_WindowCreate(hwnd, ref m_opts);
                if (Handle == null)
                {
                    throw new Exception("Failed to create View3D window");
                }
                void HandleError(IntPtr ctx, string msg, string filepath, int line, long pos) => Error?.Invoke(this, new ErrorEventArgs(msg, filepath, line, pos));

                // Set up a callback for when settings are changed
                View3D_WindowSettingsChangedCB(Handle, m_settings_cb = HandleSettingsChanged, IntPtr.Zero, true);
                void HandleSettingsChanged(IntPtr ctx, HWindow wnd, ESettings setting) => OnSettingsChanged?.Invoke(this, new SettingChangeEventArgs(setting));

                // Set up a callback for when the window is invalidated
                View3D_WindowInvalidatedCB(Handle, m_invalidated_cb = HandleInvalidated, IntPtr.Zero, true);
                void HandleInvalidated(IntPtr ctx, HWindow wnd) => OnInvalidated?.Invoke(this, EventArgs.Empty);

                // Set up a callback for when a render is about to happen
                View3D_WindowRenderingCB(Handle, m_render_cb = HandleRendering, IntPtr.Zero, true);
                void HandleRendering(IntPtr ctx, HWindow wnd) => OnRendering?.Invoke(this, EventArgs.Empty);

                // Set up a callback for when the object store for this window changes
                View3d_WindowSceneChangedCB(Handle, m_scene_changed_cb = HandleSceneChanged, IntPtr.Zero, true);
                void HandleSceneChanged(IntPtr ctx, HWindow wnd, ref View3DSceneChanged args) => OnSceneChanged?.Invoke(this, new SceneChangedEventArgs(args));

                // Set up a callback for animation events
                View3D_WindowAnimEventCBSet(Handle, m_animation_cb = HandleAnimationEvent, IntPtr.Zero, true);
                void HandleAnimationEvent(IntPtr ctx, HWindow wnd, EAnimCommand command, double clock) => OnAnimationEvent?.Invoke(this, new AnimationEventArgs(command, clock));

                // Set up the light source
                SetLightSource(v4.Origin, -v4.ZAxis, true);

                // Display the focus point
                FocusPointVisible = true;

                // Position the camera
                Camera = new Camera(this);
                Camera.Lookat(new v4(0f, 0f, -2f, 1f), v4.Origin, v4.YAxis);
            }