EDIT
How do I use E D I T
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: FormPhanQuyen.cs
Copy
45 private void btnThem_Click(object sender, EventArgs e)
46 {
47
48 if(txtTenDangNhap.Text!="")
49 {
50 if(business.Proc_Insert("Insert_Users",txtTenDangNhap.Text))
51 {
52 string sql = "'" + txtTenDangNhap.Text + "','" + txtMatKhau.Text + "','" + cmbQuyen.SelectedItem.ToString() + "'";
53 business.Insert("Users",sql);
54 FormPhanQuyen_Load(sender, e);
55 }
56 else
57 {
58 MessageBox.Show("Username này đã tồn tại");
59 }
60 }
61 }
File name: FormPhanQuyen.cs
Copy
75 private void btnSua_Click(object sender, EventArgs e)
76 {
77 string sql = "Password='" + txtMatKhau.Text + "',Quyen='" + cmbQuyen.SelectedItem.ToString() + "' where Username='"+txtTenDangNhap.Text+"'";
78 business.Update("Users",sql);
79 FormPhanQuyen_Load(sender, e);
80 }
File name: NamePickGui.cs
Copy
38 public void OnGUI()
39 {
40 // Enter-Key handling:
41 if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
42 {
43 if (!string.IsNullOrEmpty(this.InputLine))
44 {
45 this.StartChat();
46 return;
47 }
48 }
49
50
51 GUI.skin.label.wordWrap = true;
52 GUILayout.BeginArea(guiCenteredRect);
53
54
55 if (this.chatComponent != null && string.IsNullOrEmpty(this.chatComponent.ChatAppId))
56 {
57 GUILayout.Label("To continue, configure your Chat AppId.\nIt's listed in the Chat Dashboard (online).\nStop play-mode and edit:\nScripts/ChatGUI in the Hierarchy.");
58 if (GUILayout.Button("Open Chat Dashboard"))
59 {
60 Application.OpenURL("https://www.exitgames.com/en/Chat/Dashboard");
61 }
62 GUILayout.EndArea();
63 return;
64 }
65
66 GUILayout.Label(this.helpText);
67
68 GUILayout.BeginHorizontal();
69 GUI.SetNextControlName("NameInput");
70 this.InputLine = GUILayout.TextField(this.InputLine);
71 if (GUILayout.Button("Connect", GUILayout.ExpandWidth(false)))
72 {
73 this.StartChat();
74 }
75 GUILayout.EndHorizontal();
76
77 GUILayout.EndArea();
78
79
80 GUI.FocusControl("NameInput");
81 }
File name: PunStartup.cs
Copy
25 static PunStartup()
26 {
27 bool doneBefore = EditorPrefs.GetBool("PunDemosOpenedBefore");
28 if (!doneBefore)
29 {
30 EditorApplication.update += OnUpdate;
31 }
32 }
File name: PunStartup.cs
Copy
34 static void OnUpdate()
35 {
36 bool doneBefore = EditorPrefs.GetBool("PunDemosOpenedBefore");
37 if (doneBefore)
38 {
39 EditorApplication.update -= OnUpdate;
40 return;
41 }
42
43 if (String.IsNullOrEmpty(EditorApplication.currentScene) && EditorBuildSettings.scenes.Length == 0)
44 {
45 #if UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5 || UNITY_5_1 || UNITY_5_2
46 if (EditorApplication.isUpdating) return;
47 #endif
48
49 LoadPunDemoHub();
50 SetPunDemoBuildSettings();
51 EditorPrefs.SetBool("PunDemosOpenedBefore", true);
52 Debug.Log("No scene was open. Loaded PUN Demo Hub Scene and added demos to build settings. Ready to go! This auto-setup is now disabled in this Editor.");
53 }
54 }
File name: PunStartup.cs
Copy
68 public static void LoadPunDemoHub()
69 {
70 bool ret = EditorApplication.OpenScene(demoBasePath + demoPaths[0]);
71 if (ret)
72 {
73 Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(demoBasePath + demoPaths[0]);
74 }
75 }
File name: PunStartup.cs
Copy
80 public static void SetPunDemoBuildSettings()
81 {
82 // find path of pun guide
83 string[] tempPaths = Directory.GetDirectories(Application.dataPath + "/Photon Unity Networking", "Demos", SearchOption.AllDirectories);
84 if (tempPaths == null || tempPaths.Length != 1)
85 {
86 return;
87 }
88
89 // find scenes of guide
90 string guidePath = tempPaths[0];
91 tempPaths = Directory.GetFiles(guidePath, "*.unity", SearchOption.AllDirectories);
92
93 if (tempPaths == null || tempPaths.Length == 0)
94 {
95 return;
96 }
97
98 // add found guide scenes to build settings
99 List
100 for (int i = 0; i < tempPaths.Length; i++)
101 {
102 //Debug.Log(tempPaths[i]);
103 string path = tempPaths[i].Substring(Application.dataPath.Length - "Assets".Length);
104 path = path.Replace('\\', '/');
105 //Debug.Log(path);
106
107 if (path.Contains("PUNGuide_M2H"))
108 {
109 continue;
110 }
111
112 if (path.Contains("Hub"))
113 {
114 sceneAr.Insert(0, new EditorBuildSettingsScene(path, true));
115 continue;
116 }
117
118 sceneAr.Add(new EditorBuildSettingsScene(path, true));
119 }
120
121 EditorBuildSettings.scenes = sceneAr.ToArray();
122 EditorApplication.OpenScene(sceneAr[0].path);
123 }
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: 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
157 private void CheckIfStoredParametersExist()
158 {
159 for (int i = 0; i < this.m_Target.GetSynchronizedParameters().Count; ++i)
160 {
161 string parameterName = this.m_Target.GetSynchronizedParameters()[i].Name;
162 if (DoesParameterExist(parameterName) == false)
163 {
164 Debug.LogWarning("Parameter '" + this.m_Target.GetSynchronizedParameters()[i].Name +
165 "' doesn't exist anymore. Removing it from the list of synchronized parameters");
166 int numberOfRemovedElements = this.m_Target.GetSynchronizedParameters().RemoveAll(item => item.Name == parameterName);
167 EditorUtility.SetDirty(this.m_Target);
168
169 i -= numberOfRemovedElements;
170
171 if (i < 0)
172 {
173 break;
174 }
175 }
176 }
177 }
Download file with original file name:EDIT
EDIT 106 lượt xem
Gõ tìm kiếm nhanh...