Access
How do I use Access
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: HubGui.cs
Copy
28 void OnGUI()
29 {
30 GUI.skin = this.Skin;
31 GUILayout.Space(10);
32
33 GUILayout.BeginHorizontal();
34 GUILayout.Space(10);
35 scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(320));
36
37 GUILayout.Label("Basics", m_Headline);
38 if (GUILayout.Button("Demo Boxes", GUILayout.Width(280)))
39 {
40 demoDescription = "
41 demoBtn = new DemoBtn() { Text = "Start", Link = "DemoBoxes-Scene" };
42 }
43 if (GUILayout.Button("Demo Worker", GUILayout.Width(280)))
44 {
45 demoDescription = "
46 demoBtn = new DemoBtn() { Text = "Start", Link = "DemoWorker-Scene" };
47 }
48 if (GUILayout.Button("Movement Smoothing", GUILayout.Width(280)))
49 {
50 demoDescription = "
51 demoBtn = new DemoBtn() { Text = "Start", Link = "DemoSynchronization-Scene" };
52 }
53
54 GUILayout.Label("Advanced", m_Headline);
55 if (GUILayout.Button("Ownership Transfer", GUILayout.Width(280)))
56 {
57 demoDescription = "
58 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoChangeOwner-Scene" };
59 this.webLink = new DemoBtn();
60 }
61 if (GUILayout.Button("Pickup, Teams, Scores", GUILayout.Width(280)))
62 {
63 demoDescription = "
64 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoPickup-Scene" };
65 this.webLink = new DemoBtn();
66 }
67
68 GUILayout.Label("Feature Demos", m_Headline);
69 if (GUILayout.Button("Chat", GUILayout.Width(280)))
70 {
71 demoDescription = "
72 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoChat-Scene" };
73 this.webLink = new DemoBtn();
74 }
75 if (GUILayout.Button("RPG Movement", GUILayout.Width(280)))
76 {
77 demoDescription = "
78 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoRPGMovement-Scene" };
79 this.webLink = new DemoBtn();
80 }
81 if (GUILayout.Button("Mecanim Animations", GUILayout.Width(280)))
82 {
83 demoDescription = "
84 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoMecanim-Scene" };
85 this.webLink = new DemoBtn();
86 }
87 if (GUILayout.Button("2D Game", GUILayout.Width(280)))
88 {
89 demoDescription = "
90 this.demoBtn = new DemoBtn() { Text = "Start", Link = "Demo2DJumpAndRunWithPhysics-Scene" };
91 this.webLink = new DemoBtn();
92 }
93 if (GUILayout.Button("Friends & Authentication", GUILayout.Width(280)))
94 {
95 demoDescription = "
96 this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoFriends-Scene" };
97 this.webLink = new DemoBtn();
98 }
99
100 GUILayout.Label("Tutorial", m_Headline);
101 if (GUILayout.Button("Marco Polo Tutorial", GUILayout.Width(280)))
102 {
103 demoDescription = "
104 this.demoBtn = new DemoBtn() { Text = "Start", Link = "MarcoPolo-Scene" };
105 this.webLink = new DemoBtn() { Text = "Open Tutorial (www)", Link = "http://tinyurl.com/nmylf44" };
106 }
107 GUILayout.EndScrollView();
108
109 GUILayout.BeginVertical(GUILayout.Width(Screen.width - 345));
110 GUILayout.Label(demoDescription);
111 GUILayout.Space(10);
112 if (!string.IsNullOrEmpty(this.demoBtn.Text))
113 {
114 if (GUILayout.Button(this.demoBtn.Text))
115 {
116 Application.LoadLevel(this.demoBtn.Link);
117 }
118 }
119 if (!string.IsNullOrEmpty(this.webLink.Text))
120 {
121 if (GUILayout.Button(this.webLink.Text))
122 {
123 Application.OpenURL(this.webLink.Link);
124 }
125 }
126 GUILayout.EndVertical();
127
128
129 GUILayout.EndHorizontal();
130 }
File name: ChatBot.cs
Copy
52 private void showOutput()
53 {
54 if (!(string.IsNullOrWhiteSpace(InputTxt.Text))) // Make sure the textbox isnt empty
55 {
56 SoundPlayer Send = new SoundPlayer("SOUND1.wav"); // Send Sound Effect
57 SoundPlayer Rcv = new SoundPlayer("SOUND2.wav"); // Recieve Sound Effect
58
59 // Show the user message and play the sound
60 addInMessage(InputTxt.Text);
61 Send.Play();
62
63 // Store the Bot's Output by giving it our input.
64 string outtt = bot.getOutput(InputTxt.Text);
65
66 if (outtt.Length == 0)
67 {
68 outtt = "I don't understand.";
69 }
70
71 //=========== Creates backup of chat from user and bot to the given location ============
72 FileStream fs = new FileStream(@"chat.log", FileMode.Append, FileAccess.Write);
73 if (fs.CanWrite)
74 {
75 byte[] write = System.Text.Encoding.ASCII.GetBytes(InputTxt.Text + Environment.NewLine + outtt + Environment.NewLine);
76 fs.Write(write, 0, write.Length);
77 }
78 fs.Flush();
79 fs.Close();
80 //=======================================================================================
81
82 // Make a Dynamic Timer to delay the bot's response to make it feel humanlike.
83 var t = new Timer();
84
85 // Time in milseconds - minimum delay of 1s plus 0.1s per character.
86 t.Interval = 1000 + (outtt.Length * 100);
87
88 // Show the "Bot is typing.." text
89 txtTyping.Show();
90
91 // disable the chat box white the bot is typing to prevent user spam.
92 InputTxt.Enabled = false;
93
94 t.Tick += (s, d) =>
95 {
96 // Once the timer ends
97
98 InputTxt.Enabled = true; // Enable Chat box
99
100 // Hide the "Bot is typing.." text
101 txtTyping.Hide();
102
103 // Show the bot message and play the sound
104 addOutMessage(outtt);
105 Rcv.Play();
106
107 // Text to Speech if enabled
108 if (textToSpeech)
109 {
110 reader.SpeakAsync(outtt);
111 }
112
113 InputTxt.Focus(); // Put the cursor back on the textbox
114 t.Stop();
115 };
116 t.Start(); // Start Timer
117
118 InputTxt.Text = ""; // Reset textbox
119 }
120 }
Access 124 lượt xem
Gõ tìm kiếm nhanh...