Record
How do I use Record
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PhotonAnimatorViewEditor.cs
Copy
66 private void DrawWeightInspector()
67 {
68 SerializedProperty foldoutProperty = serializedObject.FindProperty("ShowLayerWeightsInspector");
69 foldoutProperty.boolValue = PhotonGUI.ContainerHeaderFoldout("Synchronize Layer Weights", foldoutProperty.boolValue);
70
71 if (foldoutProperty.boolValue == false)
72 {
73 return;
74 }
75
76 float lineHeight = 20;
77 Rect containerRect = PhotonGUI.ContainerBody(this.m_Animator.layerCount*lineHeight);
78
79 for (int i = 0; i < this.m_Animator.layerCount; ++i)
80 {
81 if (this.m_Target.DoesLayerSynchronizeTypeExist(i) == false)
82 {
83 this.m_Target.SetLayerSynchronized(i, PhotonAnimatorView.SynchronizeType.Disabled);
84 EditorUtility.SetDirty(this.m_Target);
85 }
86
87 PhotonAnimatorView.SynchronizeType value = this.m_Target.GetLayerSynchronizeType(i);
88
89 Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + i*lineHeight, containerRect.width, lineHeight);
90
91 Rect labelRect = new Rect(elementRect.xMin + 5, elementRect.yMin + 2, EditorGUIUtility.labelWidth - 5, elementRect.height);
92 GUI.Label(labelRect, "Layer " + i);
93
94 Rect popupRect = new Rect(elementRect.xMin + EditorGUIUtility.labelWidth, elementRect.yMin + 2, elementRect.width - EditorGUIUtility.labelWidth - 5, EditorGUIUtility.singleLineHeight);
95 value = (PhotonAnimatorView.SynchronizeType) EditorGUI.EnumPopup(popupRect, value);
96
97 if (i < this.m_Animator.layerCount - 1)
98 {
99 Rect splitterRect = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
100 PhotonGUI.DrawSplitter(splitterRect);
101 }
102
103 if (value != this.m_Target.GetLayerSynchronizeType(i))
104 {
105 Undo.RecordObject(target, "Modify Synchronize Layer Weights");
106 this.m_Target.SetLayerSynchronized(i, value);
107
108 EditorUtility.SetDirty(this.m_Target);
109 }
110 }
111 }
File name: PhotonAnimatorViewEditor.cs
Copy
179 private void DrawParameterInspector()
180 {
181 SerializedProperty foldoutProperty = serializedObject.FindProperty("ShowParameterInspector");
182 foldoutProperty.boolValue = PhotonGUI.ContainerHeaderFoldout("Synchronize Parameters", foldoutProperty.boolValue);
183
184 if (foldoutProperty.boolValue == false)
185 {
186 return;
187 }
188
189 float lineHeight = 20;
190 Rect containerRect = PhotonGUI.ContainerBody(GetParameterCount()*lineHeight);
191
192 for (int i = 0; i < GetParameterCount(); i++)
193 {
194 AnimatorControllerParameter parameter = null;
195
196#if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_5 || UNITY_4_6
197 parameter = this.m_Controller.GetParameter(i);
198#else
199 parameter = m_Animator.parameters[ i ];
200#endif
201
202 string defaultValue = "";
203
204 if (parameter.type == AnimatorControllerParameterType.Bool)
205 {
206 defaultValue += parameter.defaultBool.ToString();
207 }
208 else if (parameter.type == AnimatorControllerParameterType.Float)
209 {
210 defaultValue += parameter.defaultFloat.ToString();
211 }
212 else if (parameter.type == AnimatorControllerParameterType.Int)
213 {
214 defaultValue += parameter.defaultInt.ToString();
215 }
216
217 if (this.m_Target.DoesParameterSynchronizeTypeExist(parameter.name) == false)
218 {
219 this.m_Target.SetParameterSynchronized(parameter.name, (PhotonAnimatorView.ParameterType) parameter.type, PhotonAnimatorView.SynchronizeType.Disabled);
220 EditorUtility.SetDirty(this.m_Target);
221 }
222
223 PhotonAnimatorView.SynchronizeType value = this.m_Target.GetParameterSynchronizeType(parameter.name);
224
225 Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + i*lineHeight, containerRect.width, lineHeight);
226
227 Rect labelRect = new Rect(elementRect.xMin + 5, elementRect.yMin + 2, EditorGUIUtility.labelWidth - 5, elementRect.height);
228 GUI.Label(labelRect, parameter.name + " (" + defaultValue + ")");
229
230 Rect popupRect = new Rect(elementRect.xMin + EditorGUIUtility.labelWidth, elementRect.yMin + 2, elementRect.width - EditorGUIUtility.labelWidth - 5, EditorGUIUtility.singleLineHeight);
231 value = (PhotonAnimatorView.SynchronizeType) EditorGUI.EnumPopup(popupRect, value);
232
233 if (i < GetParameterCount() - 1)
234 {
235 Rect splitterRect = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
236 PhotonGUI.DrawSplitter(splitterRect);
237 }
238
239 if (value != this.m_Target.GetParameterSynchronizeType(parameter.name))
240 {
241 Undo.RecordObject(target, "Modify Synchronize Parameter " + parameter.name);
242 this.m_Target.SetParameterSynchronized(parameter.name, (PhotonAnimatorView.ParameterType) parameter.type, value);
243
244 EditorUtility.SetDirty(this.m_Target);
245 }
246 }
247 }
File name: PhotonTransformViewEditor.cs
Copy
401 private void DrawHeader(string label, SerializedProperty property)
402 {
403 if (property == null)
404 {
405 return;
406 }
407
408 bool newValue = PhotonGUI.ContainerHeaderToggle(label, property.boolValue);
409
410 if (newValue != property.boolValue)
411 {
412 Undo.RecordObject(this.m_Target, "Change " + label);
413 property.boolValue = newValue;
414 EditorUtility.SetDirty(this.m_Target);
415 }
416 }
File name: Form1.cs
Copy
254 public void NavRecords()
255 {
256
257 STUDID.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][1]);
258 TextBox1.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][2]);
259 TextBox2.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][3]);
260 TextBox3.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][4]);
261 TextBox4.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][5]);
262 TextBox5.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][6]);
263 TextBox6.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][7]);
264 TextBox7.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][8]);
265 TextBox8.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][9]);
266 TextBox9.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][10]);
267 TextBox10.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][11]);
268 TextBox11.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][12]);
269 TextBox12.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][13]);
270 TextBox13.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][14]);
271 TextBox14.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][15]);
272 TextBox15.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][16]);
273 TextBox16.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][17]);
274 TextBox17.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][18]);
275 TextBox18.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][19]);
276 TextBox19.Text = (string) (dsgrade.Tables["grade1"].Rows[inc][20]);
277
278 }
File name: Form1.cs
Copy
282 public void FRST_Click(System.Object sender, System.EventArgs e)
283 {
284 dsgrade = gradeclass.DataModule.navigate();
285 if (inc != 0)
286 {
287 inc = 0;
288 NavRecords();
289 MessageBox.Show("First Record");
290 }
291 }
File name: Form1.cs
Copy
293 public void PREV_Click(System.Object sender, System.EventArgs e)
294 {
295
296 dsgrade = gradeclass.DataModule.navigate();
297 if (inc > 0)
298 {
299 inc--;
300 NavRecords();
301 }
302 else if (inc == -1)
303 {
304 MessageBox.Show("No Records Yet");
305 }
306 else if (inc == 0)
307 {
308 MessageBox.Show("First Record");
309 }
310
311
312 }
File name: Form1.cs
Copy
314 public void LAST_Click(System.Object sender, System.EventArgs e)
315 {
316 dsgrade = gradeclass.DataModule.navigate();
317 MaxRows = dsgrade.Tables["grade1"].Rows.Count;
318 if (inc != MaxRows)
319 {
320 inc = MaxRows - 1;
321 NavRecords();
322 }
323 else
324 {
325 MessageBox.Show("Last Record");
326 }
327 }
File name: Form1.cs
Copy
329 public void NXT_Click(System.Object sender, System.EventArgs e)
330 {
331 dsgrade = gradeclass.DataModule.navigate();
332 try
333 {
334 if (inc != MaxRows - 1)
335 {
336 inc++;
337 NavRecords();
338 }
339 }
340 catch (Exception)
341 {
342 MessageBox.Show("No More Rows");
343 }
344 }
File name: Form1.cs
Copy
373 public void Button11_Click(System.Object sender, System.EventArgs e)
374 {
375 string strmessage = default(string);
376 DialogResult dgrResult;
377
378 strmessage = "Are you sure you want to Delete this record?";
379 dgrResult = MessageBox.Show(strmessage, "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
380
381
382 if (dgrResult == System.Windows.Forms.DialogResult.Yes)
383 {
384
385 dsgrade = gradeclass.DataModule.deldata();
386
387 }
388
389
390
391 }
File name: SortingLayerExposedEditor.cs
Copy
15 public override void OnInspectorGUI()
16 {
17 // Get the renderer from the target object
18 var renderer = (target as SortingLayerExposed).gameObject.GetComponent
19
20 // If there is no renderer, we can't do anything
21 if (!renderer)
22 {
23 return;
24 }
25
26 // Expose the sorting layer name
27 //string newSortingLayerName = EditorGUILayout.TextField("Sorting Layer", renderer.sortingLayerName);
28 //if (newSortingLayerName != renderer.sortingLayerName)
29 //{
30 // Undo.RecordObject(renderer, "Edit Sorting Layer Name");
31 // renderer.sortingLayerName = newSortingLayerName;
32 // EditorUtility.SetDirty(renderer);
33 //}
34
35 // Expose the sorting layer ID
36 //int newSortingLayerId = EditorGUILayout.IntField("Sorting Layer ID", renderer.sortingLayerID);
37 //if (newSortingLayerId != renderer.sortingLayerID)
38 //{
39 // Undo.RecordObject(renderer, "Edit Sorting Layer ID");
40 // renderer.sortingLayerID = newSortingLayerId;
41 // EditorUtility.SetDirty(renderer);
42 //}
43
44 // Seanba: Use a popup that is populated with the acceptable sorting layers for the renderer
45 // Also allow the player to bring up the Tag/Layers inspector if they choose so
46 string[] sortLayerNames = GetSortingLayerNames();
47 //int[] sortLayerIds = GetSortingLayerUniqueIDs();
48 //{
49 // StringBuilder builder = new StringBuilder("Sorting Layers = ");
50 // for (int i = 0; i < sortLayerNames.Length; ++i)
51 // {
52 // builder.AppendFormat("({0} = {1},{2}) ", i, sortLayerIds[i], sortLayerNames[i]);
53 // }
54 // Debug.Log(builder.ToString());
55 //}
56
57 int sortLayerSelection = GetSortingLayerIndex(renderer, sortLayerNames);
58
59 GUIContent[] sortingLayerContexts = GetSortingLayerContexts();
60 int newSortingLayerIndex = EditorGUILayout.Popup(new GUIContent("Sorting Layer"), sortLayerSelection, sortingLayerContexts);
61 if (newSortingLayerIndex == sortingLayerContexts.Length - 1)
62 {
63 EditorApplication.ExecuteMenuItem("Edit/Project Settings/Tags and Layers");
64 }
65 else if (newSortingLayerIndex != sortLayerSelection)
66 {
67 //int newSortingLayerId = sortLayerIds[newSortingLayerIndex];
68 string newSortingLayerName = sortLayerNames[newSortingLayerIndex];
69
70 Undo.RecordObject(renderer, "Edit Sorting Layer ID");
71 renderer.sortingLayerName = newSortingLayerName;
72 //renderer.sortingLayerID = newSortingLayerId;
73
74 EditorUtility.SetDirty(renderer);
75 }
76
77 // Expose the manual sorting order within a sort layer
78 int newSortingLayerOrder = EditorGUILayout.IntField("Order in Layer", renderer.sortingOrder);
79 if (newSortingLayerOrder != renderer.sortingOrder)
80 {
81 Undo.RecordObject(renderer, "Edit Sorting Order");
82 renderer.sortingOrder = newSortingLayerOrder;
83 EditorUtility.SetDirty(renderer);
84 }
85 }
Download file with original file name:Record
Record 106 lượt xem
Gõ tìm kiếm nhanh...