Repeat
How do I use Repeat
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PickupCamera.cs
Copy
86 float AngleDistance( float a, float b )
87 {
88 a = Mathf.Repeat( a, 360 );
89 b = Mathf.Repeat( b, 360 );
90
91 return Mathf.Abs( b - a );
92 }
File name: ThirdPersonCamera.cs
Copy
78 float AngleDistance( float a, float b )
79 {
80 a = Mathf.Repeat( a, 360 );
81 b = Mathf.Repeat( b, 360 );
82
83 return Mathf.Abs( b - a );
84 }
File name: SupportLogger.cs
Copy
26 public void Start()
27 {
28 if (LogTrafficStats)
29 {
30 this.InvokeRepeating("LogStats", 10, 10);
31 }
32 }
File name: TimerScript.cs
Copy
53 public void InitTimer() {
54 //set time remaining if it doesn't exist yet
55 if (!PlayerPrefs.HasKey ("timer_time_remaining")){
56 this.timeRemaining = PlayerPrefs.GetInt("options_timer_duration");
57 PlayerPrefs.SetInt ("timer_time_remaining", this.timeRemaining);
58 }
59 else {
60 this.timeRemaining = PlayerPrefs.GetInt ("timer_time_remaining");
61 }
62 PlayerPrefs.Save ();
63
64
65 CancelInvoke ("TimeChange");
66 if (PlayerPrefs.GetInt ("options_timer_duration") > 0) {
67 this.timerEnabled = true;
68 InvokeRepeating ("TimeChange", 1, 1);
69 }
70 else {
71 this.timerEnabled = false;
72 }
73 }
File name: NextGuideClickListener.cs
Copy
13 public void Start()
14 {
15 gameObject.AddComponent
16 new ActionScaleTo(0.9f, 0.9f, 0.2f, Interpolation.sine),
17 new ActionScaleTo(1, 1, 0.2f, Interpolation.sine)
18 )));
19 guideIndex = 0;
20 }
File name: ButtonStartClickListener.cs
Copy
10 public void Start()
11 {
12 gameObject.AddComponent
13 new ActionScaleTo(0.75f, 0.75f, 0.2f, Interpolation.sine),
14 new ActionScaleTo(0.8f, 0.8f, 0.2f, Interpolation.sine)
15 )));
16 }
File name: BoardLevel.cs
Copy
18 public void Start () {
19 int levelUnlock = Data.getData(Data.KEY_LEVEL + Attr.currentWorld);
20
21 createHeadTexts(Attr.currentWorld);
22
23 float[] lxs = new float[] { -3, -1.5f, 0, 1.5f, 3, -3, -1.5f, 0, 1.5f, 3, -3, -1.5f, 0, 1.5f, 3 };
24 float[] lys = new float[] { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1 };
25 for (int i = 0; i < 15; i++)
26 {
27 GameObject levelObject = (GameObject)Instantiate(prefabs);
28 levelObject.transform.parent = gameObject.transform;
29 levelObject.transform.localPosition = new Vector3(lxs[i], lys[i], -1);
30 FontLevel fontLevel = levelObject.GetComponent
31 fontLevel.setBoardLevel(this);
32
33 //fontLevel.setText("" + (i + 1));
34 fontLevel.setText(i < levelUnlock ? heads[i] : hs[i]);
35
36 fontLevel.setStar(Data.getData(Data.KEY_STAR + (Attr.currentWorld * 15 + i)), i < levelUnlock);
37
38 if (i < levelUnlock)
39 {
40 fontLevel.bgObject.GetComponent
41
42 if (i == levelUnlock - 1)
43 {
44 levelObject.AddComponent
45 new ActionScaleTo(0.95f, 0.95f, 0.2f, Interpolation.sine),
46 new ActionScaleTo(1, 1, 0.2f, Interpolation.sine)
47 )));
48
49 }
50
51 addClickListener(fontLevel.bgObject, i);
52 }
53 else
54 fontLevel.bgObject.GetComponent
55 }
56
57 gameObject.AddComponent
58 new ActionScaleTo(0, 0, 0),
59 new ActionScaleTo(1, 1, 0.5f, Interpolation.swingOut)));
60 }
File name: Buttons.cs
Copy
12 public void Start()
13 {
14 float[] btX = new float[] { 3.3f, 3.55f};
15 for (int i = 0; i < buttons.Count; i++)
16 {
17 buttons[i].GetComponent
18 if (i == 0)
19 {
20 buttons[i].GetComponent
21 }
22 }
23 }
File name: MainMenuAnimals.cs
Copy
11 public void Start()
12 {
13 for (int i = 0; i < 3; i++)
14 animals[i].GetComponent
15
16 gameObject.AddComponent
17 delegate() {
18 SoundManager.LoadBgMusic("Sounds/menu", false);
19 SoundManager.playSound("Sounds/roga");
20 }
21 )));
22
23 float[] aY = new float[] { 0.01f, 0.01f, -0.02f };
24 float[] ds = new float[] { 0.2f, 0.4f, 0.3f };
25 for (int i = 0; i < 3; i++)
26 {
27 animals[i].GetComponent
28 new ActionMoveTo(animals[i].transform.localPosition.x, aY[i] + 0.1f, 1 + ds[i], Interpolation.sine),
29 new ActionMoveTo(animals[i].transform.localPosition.x, aY[i], 1 + ds[i], Interpolation.sine)
30 )));
31 }
32 }
File name: TouchText.cs
Copy
10 public void Start()
11 {
12 Data.InitData();
13 InputController.Enabled = false;
14
15 gameObject.GetComponent
16 new ActionDelay(2),
17 new ActionMoveTo(0, -1.85f, 0.1f, Interpolation.sine),
18 new ActionRunnable(delegate() { enableInput(); })
19 ));
20
21 text.GetComponent
22 new ActionRepeat(ActionRepeat.FOREVER, new ActionSequence(
23 new ActionColorTo(1, 1, 1, 1, 0.1f), new ActionColorTo(1, 1, 1, 0, 0.1f)
24 ))));
25 }
Download file with original file name:Repeat
Repeat 140 lượt xem
Gõ tìm kiếm nhanh...