OptionsScript
How do I use Options Script
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
62 | this.options = this.gameObject.GetComponent ("OptionsScript") as OptionsScript; | 1 |
17 | this.options = this.gameObject.GetComponent ("OptionsScript") as OptionsScript; | 2 |
File name: GameControllerScript.cs
Copy
48 void Start (){
49
50 int x;
51 int y;
52 int z;
53 int axis;
54 yOffset = 1F;
55 Transform blockInstance;
56 BlockScript blockScript;
57 ConnectorScript connectorScript;
58 Transform connectorInstance;
59 TextMesh textMesh;
60
61 this.gameView = "menu";
62 this.options = this.gameObject.GetComponent ("OptionsScript") as OptionsScript;
63 this.timer = this.gameObject.GetComponent ("TimerScript") as TimerScript;
64 this.sizeGUI();
65
66 this.options.InitOptions();
67
68 //setup audio sources
69
70 AudioSource[] audioSources = GetComponents
71 this.swipeAudioSource = audioSources[0];
72 this.collideAudioSource = audioSources[1];
73 this.collideAudioSource.clip = this.collideSound;
74
75 //instantiate the blocks and connectors and position them
76 for (x = 0; x <= 2; x++) {
77 for (y = 0; y <= 2; y++) {
78 for (z = 0; z <= 2; z++) {
79 //instantiate the block
80 blockInstance = Instantiate (block, new Vector3(x * this.scale, y * this.scale + this.yOffset, z * this.scale), Quaternion.identity) as Transform;
81 this.blocks[x,y,z] = blockInstance;
82 blockScript = blockInstance.gameObject.GetComponent("BlockScript") as BlockScript;
83 blockScript.Initialize(x,y,z,this);
84 }
85 }
86 }
87
88 // instantiate the connectors
89 for (x = 0; x <= 2; x++) {
90 for (y = 0; y <= 2; y++) {
91 for (z = 0; z <= 2; z++) {
92 //instantiate the x connector
93 connectorInstance = Instantiate (connector) as Transform;
94 connectorScript = connectorInstance.gameObject.GetComponent("ConnectorScript") as ConnectorScript;
95 connectorScript.Initialize(x,y,z,"x", this);
96 this.connectors[x,y,z,0] = connectorInstance;
97
98 //instantiate the y connector
99 connectorInstance = Instantiate (connector) as Transform;
100 connectorScript = connectorInstance.gameObject.GetComponent("ConnectorScript") as ConnectorScript;
101 connectorScript.Initialize(x,y,z,"y", this);
102 this.connectors[x,y,z,1] = connectorInstance;
103
104 //instantiate the z connector
105 connectorInstance = Instantiate (connector) as Transform;
106 connectorScript = connectorInstance.gameObject.GetComponent("ConnectorScript") as ConnectorScript;
107 connectorScript.Initialize(x,y,z,"z", this);
108 this.connectors[x,y,z,2] = connectorInstance;
109 }
110 }
111 }
112
113 //instantiate the move blocks
114 if (PlayerPrefs.HasKey ("game_status")) {
115 this.loadSavedGame();
116 }
117 else {
118 this.restart ();
119 }
120 }
File name: TimerScript.cs
Copy
15 void Start () {
16 this.gameScript = this.gameObject.GetComponent ("GameControllerScript") as GameControllerScript;
17 this.options = this.gameObject.GetComponent ("OptionsScript") as OptionsScript;
18 this.currentGUISkin = gameScript.currentGUISkin;
19 this.InitTimer ();
20
21 AudioSource[] audioSources = GetComponents
22 this.countdownAudioSource = audioSources[2];
23 countdownAudioSource.clip = this.countdownSound;
24 }
Download file with original file name:OptionsScript
OptionsScript 132 lượt xem
Gõ tìm kiếm nhanh...