LateUpdate









How do I use Late Update
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PickupCamera.cs Copy
175     void LateUpdate()
176     {
177         Apply( transform, Vector3.zero );
178     }
File name: RPGCamera.cs Copy
30     void LateUpdate()
31     {
32         UpdateDistance();
33         UpdateZoom();
34         UpdatePosition();
35         UpdateRotation();
36     }
File name: ThirdPersonCamera.cs Copy
167     void LateUpdate()
168     {
169         Apply( transform, Vector3.zero );
170     }
File name: GameScreen.cs Copy
379         public void LateUpdate()
380         {
381             if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space))
382             {
383                 if (InputController.Name == InputNames.GAMESCREEN)
384                 {
385                     if (InputController.IsScreen)
386                     {
387                         if(Time.timeScale != 0)
388                             animals.getAnimal(0).GetComponent().Jump();
389                         //createBuiTien(-1.2f, 1f);
390                     }
391                 }
392             }
393             else if (Input.GetMouseButtonUp(0))
394             {
395                 InputController.IsScreen = true;
396             }
397             if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Backspace))
398             {
399                 if (!isPrepare)
400                 {
401                     if (dialog != null && dialog.activeSelf && InputController.Name == InputNames.DIALOG)
402                     {
403                         dialog.GetComponent().hideDialog();
404                         pauseLayer.SetActive(true);
405                     }else if (InputController.Name == InputNames.GAMESCREEN)
406                     {
407                         pauseGame();
408                         dialog.GetComponent().showDialog();
409                         pauseLayer.SetActive(false);
410                     }
411                     else if (pauseLayer.activeSelf)
412                     {
413                         resumeGame();
414                     }
415                 }
416             }
417             if (isPrepare)
418             {
419                 isPrepare = false;
420
421                 buttonSkills.setFonts(shopFont);
422                 prepareGame();
423             }
424         }
File name: ScrollSnap.cs Copy
336         void LateUpdate()
337         {
338             UpdateListItemsSize();
339             UpdateListItemPositions();
340
341             if (lerp)
342             {
343                 UpdateScrollbar(false);
344
345                 listContainerTransform.localPosition = Vector3.Lerp(listContainerTransform.localPosition, lerpTarget, 7.5f * Time.deltaTime);
346
347                 if (Vector3.Distance(listContainerTransform.localPosition, lerpTarget) < 0.001f)
348                 {
349                     listContainerTransform.localPosition = lerpTarget;
350                     lerp = false;
351
352                     UpdateScrollbar(linkScrolbarSteps);
353                 }
354
355                 //change the info bullets at the bottom of the screen. Just for visual effect
356                 if (Vector3.Distance(listContainerTransform.localPosition, lerpTarget) < 10f)
357                 {
358                     PageChanged(CurrentPage());
359                 }
360             }
361
362             if (fastSwipeTimer)
363             {
364                 fastSwipeCounter++;
365             }
366         }
File name: TouchText.cs Copy
33         public void LateUpdate()
34         {
35             if (InputController.Enabled && InputController.Name == InputNames.MAINMENU)
36             {
37                 if (Input.GetButtonDown("Fire1") && InputController.IsScreen)
38                 {
39                     SceneManager.LoadScene("MapScreen");
40                 }
41                 else if (Input.GetMouseButtonUp(0))
42                 {
43                     InputController.IsScreen = true;
44                 }
45             }
46         }
File name: ShopScreen.cs Copy
88     public void LateUpdate()
89     {
90         if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Backspace))
91         {
92             if (InputController.Name == InputNames.DIALOG)
93             {
94                 if (dialog != null)
95                 {
96                     dialog.GetComponent().hideDialog();
97                     InputController.Name = InputNames.SHOP;
98                 }
99             }
100         }
101     }
File name: ScrollSnap.cs Copy
52  void LateUpdate() {
53   if(isLerping) {
54    LerpToElement();
55    if(ShouldStopLerping()) {
56     isLerping = false;
57     canvasGroup.blocksRaycasts = true;
58     onLerpComplete.Invoke();
59     onLerpComplete.RemoveListener(WrapElementAround);
60    }
61   }
62  }

LateUpdate 138 lượt xem

Gõ tìm kiếm nhanh...