Events
How do I use Events
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: frmCapNhat.cs
Copy
367 private void buton1_Click(object sender, EventArgs e)
368 {
369 float i = 50;
370 if (buton1.Text == "Thu Nhỏ")
371 {
372 while (this.Height > 370)
373 {
374 i += 1f;
375 this.Height -= (int)i;
376 Application.DoEvents();
377 buton1.Text = "Mở Rộng";
378 }
379 }
380 else
381 {
382
383 while (this.Height < 600)
384 {
385 i += 1f;
386 this.Height += (int)i;
387 Application.DoEvents();
388 buton1.Text = "Thu Nhỏ";
389 }
390 }
391 }
File name: NetworkingPeer.cs
Copy
2780 /// This clears the cache of any player/actor who's no longer in the room (making it a simple clean-up option for a new master)
2781 private void RemoveCacheOfLeftPlayers()
2782 {
2783 Dictionary
2784 opParameters[ParameterCode.Code] = (byte)0; // any event
2785 opParameters[ParameterCode.Cache] = (byte)EventCaching.RemoveFromRoomCacheForActorsLeft; // option to clear the room cache of all events of players who left
2786
2787 this.OpCustom((byte)OperationCode.RaiseEvent, opParameters, true, 0);
2788 }
File name: LevelController.cs
Copy
38 public void LevelSelect(){
39 string level = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject.name;
40
41 switch(level){
42 case "Level 1":
43 if(GameController.instance != null){
44 GameController.instance.currentLevel = 1;
45 }
46 break;
47
48 case "Level 2":
49 if(GameController.instance != null){
50 GameController.instance.currentLevel = 2;
51 }
52 break;
53
54 case "Level 3":
55 if(GameController.instance != null){
56 GameController.instance.currentLevel = 3;
57 }
58 break;
59
60 case "Level 4":
61 if(GameController.instance != null){
62 GameController.instance.currentLevel = 4;
63 }
64 break;
65
66 case "Level 5":
67 if(GameController.instance != null){
68 GameController.instance.currentLevel = 5;
69 }
70 break;
71
72 case "Level 6":
73 if(GameController.instance != null){
74 GameController.instance.currentLevel = 6;
75 }
76 break;
77
78 case "Level 7":
79 if(GameController.instance != null){
80 GameController.instance.currentLevel = 7;
81 }
82 break;
83
84 case "Level 8":
85 if(GameController.instance != null){
86 GameController.instance.currentLevel = 8;
87 }
88 break;
89
90 case "Level 9":
91 if(GameController.instance != null){
92 GameController.instance.currentLevel = 9;
93 }
94 break;
95
96 case "Level 10":
97 if(GameController.instance != null){
98 GameController.instance.currentLevel = 10;
99 }
100 break;
101
102 case "Level 11":
103 if(GameController.instance != null){
104 GameController.instance.currentLevel = 11;
105 }
106 break;
107
108 case "Level 12":
109 if(GameController.instance != null){
110 GameController.instance.currentLevel = 12;
111 }
112 break;
113
114 case "Level 13":
115 if(GameController.instance != null){
116 GameController.instance.currentLevel = 13;
117 }
118 break;
119
120 case "Level 14":
121 if(GameController.instance != null){
122 GameController.instance.currentLevel = 14;
123 }
124 break;
125
126 case "Level 15":
127 if(GameController.instance != null){
128 GameController.instance.currentLevel = 15;
129 }
130 break;
131
132 }
133
134 SceneManager.LoadScene (level);
135
136 }
File name: AnimationBuilder.cs
Copy
91 public AnimationClip MakeAnimationClip(GameObject root, Animation animation, string baseFolderPath)
92 {
93 //Clear local caches
94 lastGameObjectCache.Clear();
95 animationEvents.Clear();
96 lastKeyframeCache.Clear();
97 spriteChangeKeys.Clear();
98 spriteBaseFolder = baseFolderPath;
99
100 var animClip = new AnimationClip();
101 animClip.name = animation.Name;
102
103 //Set clip to Generic type
104 //AnimationUtility.SetAnimationType(animClip, ModelImporterAnimationType.Generic);
105
106 //Populate the animation curves & events
107 MakeAnimationCurves(root, animClip, animation);
108
109 return animClip;
110 }
Events 96 lượt xem
Gõ tìm kiếm nhanh...