Initialize() private method

private Initialize ( ) : void
return void
Beispiel #1
0
    void Start()
    {
        // 然后在这里获取到刚才定义的刚体组件
        _rigidbody = GetComponent <Rigidbody>();

        // 由于此时Player的中心还是在中间,容易摔倒,因此把重心挪到Player底部,不容易摔倒
        _rigidbody.centerOfMass = new Vector3(0, 0, 0);

        // 当前位置就是所在的Stage
        _currentStage = Stage;

        // 游戏开始将上一个所在盒子初始化为当前盒子,即第一个盒子
        _lastCollisionCollider = _currentStage.GetComponent <Collider>();

        // 游戏一开始就生成一个盒子
        SpawnStage();

        // 一开始用相机的位置 - Player的位置,就得到相机的相对位置
        _cameraRelativePosition = Camera.position - transform.position;

        // 用脚本来绑定事件
        SaveButton.onClick.AddListener(OnClickSaveButton);

        RestartButton.onClick.AddListener(() => {
            SceneManager.LoadScene(0);
        });

        // 初始化一下
        MainThreadDispatcher.Initialize();
    }
Beispiel #2
0
        void Awake()
        {
            MainThreadDispatcher.Initialize();

            button1.OnClickAsObservable().Subscribe(async _ =>
            {
                await StandardWWW();
            });

            button2.OnClickAsObservable().Subscribe(async _ =>
            {
                await ThraedingError();
            });

            button3.OnClickAsObservable().Subscribe(async _ =>
            {
                await UniRxSynchronizationContextSolves();
            });

            button4.OnClickAsObservable().Subscribe(async _ =>
            {
                await CoroutineBridge();
            });

            button5.OnClickAsObservable().Subscribe(async _ =>
            {
                await CoroutineBridge2();
            });
        }
Beispiel #3
0
        public void Awake()
        {
            MainThreadDispatcher.Initialize();

            //LogHelper.LogCallbackAsObservable()
            //    .ObserveOnMainThread()
            //    .Where(x => x.LogType == LogType.Exception)
            //    .Subscribe(x => logtext.AppendLine(x.ToString()));

            //ObservableLogger.Listener.LogToUnityDebug();
            //ObservableLogger.Listener.ObserveOnMainThread().Subscribe(x =>
            //{
            //    logtext.AppendLine(x.Message);
            //});

#if UNITY_5_3
            button.OnClickAsObservable().Subscribe(_ =>
            {
                UnityEngine.Debug.Log("---");
                Observable.EveryGameObjectUpdate().Subscribe(x => Debug.Log("EveryGameObjectUpdate" + x));
                Observable.EveryUpdate().Subscribe(x => Debug.Log("EveryUpdate:" + x));
                Observable.EveryAfterUpdate().Subscribe(x => Debug.Log("EveryAfterUpdate:" + x));
                Observable.EveryLateUpdate().Subscribe(x => Debug.Log("EveryLateUpdate:" + x));
                Observable.EveryEndOfFrame().Subscribe(x => Debug.Log("EveryEndOfFrame:" + x));
                UnityEngine.Debug.Log("---");
            });
#endif
        }
Beispiel #4
0
        void Start()
        {
            // UnitTest uses Wait, it can't run on MainThreadScheduler.
            Scheduler.DefaultSchedulers.SetDotNetCompatible();
            MainThreadDispatcher.Initialize();

            new UnityTestDriver().Run(this.buttonPrefab, this.buttonVertical, this.resultPrefab, this.resultVertical);
        }
Beispiel #5
0
        void Start()
        {
            // UnitTest uses Wait, it can't run on MainThreadScheduler.
            Scheduler.DefaultSchedulers.SetDotNetCompatible();
            MainThreadDispatcher.Initialize();

            UnitTests.SetButtons(buttonPrefab, buttonVertical, resultPrefab, resultVertical);
        }
 void Start()
 {
     Debug.Log("Customnetworkmanager Start");
     DontDestroyOnLoad(this);
     MainThreadDispatcher.Initialize();
     ClientHandleData.InitializePackets();
     ClientTCP.InitializingNetworking();
 }
Beispiel #7
0
        public void Awake()
        {
            MainThreadDispatcher.Initialize();

            LogHelper.LogCallbackAsObservable()
            .ObserveOnMainThread()
            .Where(x => x.LogType == LogType.Exception)
            .Subscribe(x => logtext.AppendLine(x.ToString()));

            ObservableLogger.Listener.LogToUnityDebug();
            ObservableLogger.Listener.ObserveOnMainThread().Subscribe(x =>
            {
                logtext.AppendLine(x.Message);
            });
        }
Beispiel #8
0
        private void LoadAndRun(ReactScript script, List <TextAsset> preload, Action callback = null, bool disableWarnings = false)
        {
            MainThreadDispatcher.Initialize();
            int debounce = -1;

            ScriptWatchDisposable = script.GetScript((code, isDevServer) =>
            {
                if (debounce >= 0)
                {
                    MainThreadDispatcher.StopDeferred(debounce);
                }
                debounce = MainThreadDispatcher.Timeout(() => RunScript(code, isDevServer, script, preload, callback), 0.5f);
            }, out var result, true, disableWarnings);
            RunScript(result, false, script, preload, callback);
        }
Beispiel #9
0
        public override void Awake()
        {
            Debug.Log("Awake");

            ObservableLogger.Listener.LogToUnityDebug();

            MainThreadDispatcher.Initialize();
            threadstaticobj = new object();

            ObservableLogger.Listener.ObserveOnMainThread().Subscribe(x =>
            {
                logtext.AppendLine(x.Message);
            });

            base.Awake();
        }
Beispiel #10
0
        public override void Awake()
        {
            Debug.Log("Awake");

            ObservableLogger.Listener.LogToUnityDebug();

            text = GameObject.Find("myGuiText");
            MainThreadDispatcher.Initialize();
            threadstaticobj = new object();

            ObservableLogger.Listener.ObserveOnMainThread().Subscribe(x =>
            {
                text.guiText.text = x.ToString();
            });

            base.Awake();
        }
Beispiel #11
0
        //public Matrix4x4 MXX;

        public void Awake()
        {
            Debug.Log("Awake");
            LogHelper.LogCallbackAsObservable()
            .ObserveOnMainThread()
            .Subscribe(x => logtext.AppendLine(x.ToString()));


            ObservableLogger.Listener.LogToUnityDebug();

            cube    = GameObject.CreatePrimitive(PrimitiveType.Cube);
            clicker = cube.AddComponent <Clicker>();



            MainThreadDispatcher.Initialize();
            threadstaticobj = new object();


            ObservableLogger.Listener.ObserveOnMainThread().Subscribe(x =>
            {
                logtext.AppendLine(x.Message);
            });


            // Intxxx.Subscribe(x => Debug.Log(x));
            LongxXXX.Subscribe(x => Debug.Log(x));
            DuAAX.Subscribe(x => Debug.Log(x));
            FloAAX.Subscribe(x => Debug.Log(x));
            Booxxx.Subscribe(x => Debug.Log(x));
            MikanRP.Subscribe(x => Debug.Log(x));
            Strrrrr.Subscribe(x => Debug.Log(x));

            USHHHH.Subscribe(x => Debug.Log(x));

            AAA.Subscribe(x => Debug.Log(x));
            BBB.Subscribe(x => Debug.Log(x));
            CCC.Subscribe(x => Debug.Log(x));
            DDD.Subscribe(x => Debug.Log(x));
            EEE.Subscribe(x => Debug.Log(x));
            FFF.Subscribe(x => Debug.Log(x));
            GGG.Subscribe(x => Debug.Log(x));
            HHH.Subscribe(x => Debug.Log(x));

            SUPER_Rx.Subscribe(x => Debug.Log(x.ToString()));
        }
Beispiel #12
0
        void Start()
        {
            MainThreadDispatcher.Initialize();
            Application.targetFrameRate = -1;
            UniRx.MainThreadDispatcher.Initialize();
            LeanTween.init(20000);
            DOTween.Init(null, false, null);

            // Command
            var canExecute = new ReactiveProperty <bool>(true);

            buttonReMotion.BindOnClick(canExecute, _ => RunTween("ReMotion", xxx => xxx.transform.TweenPosition(new Vector3(10, 10, 10), 3.0f, EasingFunctions.Linear)));
            buttonDoTween.BindOnClick(canExecute, _ => RunTween("DOTween", xxx => xxx.transform.DOMove(new Vector3(10, 10, 10), 3f).SetEase(Ease.Linear)));
            buttonLeanTween.BindOnClick(canExecute, _ => RunTween("LeanTween", xxx => LeanTween.move(xxx, new Vector3(10, 10, 10), 3.0f).setEase(LeanTweenType.linear)));
            buttoniTween.BindOnClick(canExecute, _ => RunTween("iTween", xxx => iTween.MoveTo(xxx, new Vector3(10f, 10f, 10f), 3.0f)));
            buttonUween.BindOnClick(canExecute, _ => RunTween("Uween", xxx => Uween.TweenXYZ.Add(xxx, 3.0f, new Vector3(10, 10, 10))));
        }
Beispiel #13
0
        void Start()
        {
            MainThreadDispatcher.Initialize();
            Application.targetFrameRate = -1;

            original = target.transform.position;
            from     = original.x;
            to       = 2.0f;
            diff     = to - from;

            texture                  = new Texture2D(600, 600, TextureFormat.ARGB32, false);
            graph.texture            = texture;
            graph.texture.filterMode = FilterMode.Point;
            ResetGraph();

            UniRx.MainThreadDispatcher.Initialize();
            LeanTween.init(20000);
        }
Beispiel #14
0
    // Use this for initialization
    void Start()
    {
        _rigidbody = GetComponent <Rigidbody>();
        _rigidbody.centerOfMass = Vector3.zero;
        _currentStage           = Stage;
        _lastCollisiomCollider  = _currentStage.GetComponent <Collider>();
        SpawnStage();

        _cameraRelativePosition = Camera.position - transform.position;

        SaveButton.onClick.AddListener(OnClickSaveButton);
        RestartButton.onClick.AddListener(() =>
        {
            SceneManager.LoadScene(0);
        });

        MainThreadDispatcher.Initialize();
    }
Beispiel #15
0
        public void Start()
        {
            Debug.Log("Start");

            // DoubleCLick Sample of
            // The introduction to Reactive Programming you've been missing
            // https://gist.github.com/staltz/868e7e9bc2a7b8c1f754

            /*
             * var clickStream = Observable.EveryUpdate()
             *  .Where(_ => Input.GetMouseButtonDown(0));
             *
             * clickStream.Buffer(clickStream.Throttle(TimeSpan.FromMilliseconds(250)))
             *  .Where(xs => xs.Count >= 2)
             *  .Subscribe(xs => Debug.Log("DoubleClick Detected! Count:" + xs.Count));
             */

            MainThreadDispatcher.Initialize();
        }
Beispiel #16
0
 void OnEnable()
 {
     MainThreadDispatcher.Initialize();
     Restart();
 }
Beispiel #17
0
 void Awake()
 {
     MainThreadDispatcher.Initialize();
 }
Beispiel #18
0
 // Use this for initialization
 void Start()
 {
     MainThreadDispatcher.Initialize();
 }
Beispiel #19
0
    //
    // 初始化
    //
    void Start()
    {
        _rigidbody = GetComponent <Rigidbody>();

        //粒子效果
        Particle = GameObject.Find("Yellow");
        Particle.SetActive(false);

        //降低重心至物体底部
        _rigidbody.centerOfMass = Vector3.zero;

        _currentStage          = Stage;
        _lastCollisionCollider = _currentStage.GetComponent <Collider>();
        SpawnStage();

        //相机相对位置=相机位置-小人位置
        _cameraRelativePosition = Camera.position - transform.position;

        //
        //给保存按钮绑定事件
        //

        //开始界面按钮
        ShowLoginPanel.onClick.AddListener(OnClickShowLoginPanel);
        ShowRegisterPanel.onClick.AddListener(OnClickShowRegisterPanel);
        ShowListButton.onClick.AddListener(OnClickShowListButton);
        StratButton.onClick.AddListener(OnClickStartButton);
        //上传界面按钮
        SaveButton.onClick.AddListener(OnClickSaveButton);
        RestartButton.onClick.AddListener(OnClickRestartButton);
        //排行榜界面按钮
        RestartButton2.onClick.AddListener(OnClickRestartButton);
        //注册登陆界面按钮
        ReturnButton1.onClick.AddListener(OnClickReturnButton1);
        ReturnButton2.onClick.AddListener(OnClickReturnButton2);
        LoginButton.onClick.AddListener(OnClickLoginButton);
        RegisterButton.onClick.AddListener(OnClickRegisterButton);
        //消息响应窗口按钮
        InfButton.onClick.AddListener(() =>
        {
            Inf.SetActive(false);
        });

        SoundsButton.onClick.AddListener(OnClickSoundsButton);
        ConstRestartButton.onClick.AddListener(OnClickRestartButton);

        //初始化
        Users.text   = "当前用户:" + _nowUsername;
        _enableInput = false;
        ScoreText.gameObject.SetActive(true);
        StartPanel.SetActive(true);
        MainThreadDispatcher.Initialize();

        _audioSource      = this.gameObject.AddComponent <AudioSource>();
        _audioSource.clip = music;

        if (isOnPlay)
        {
            _audioSource.Play();
            SoundsText.text = "音效:开";
        }
        else
        {
            _audioSource.Pause();
            SoundsText.text = "音效:关";
        }
    }
 public static void Init()
 {
     MainThreadDispatcher.Initialize();
 }