Guid
How do I use Guid
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
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: ServerSettingsInspector.cs
Copy
17 public override void OnInspectorGUI()
18 {
19 ServerSettings settings = (ServerSettings)this.target;
20
21 #if UNITY_3_5
22 EditorGUIUtility.LookLikeInspector();
23 #endif
24
25
26 settings.HostType = (ServerSettings.HostingOption)EditorGUILayout.EnumPopup("Hosting", settings.HostType);
27 EditorGUI.indentLevel = 1;
28
29 switch (settings.HostType)
30 {
31 case ServerSettings.HostingOption.BestRegion:
32 case ServerSettings.HostingOption.PhotonCloud:
33 if (settings.HostType == ServerSettings.HostingOption.PhotonCloud)
34 settings.PreferredRegion = (CloudRegionCode)EditorGUILayout.EnumPopup("Region", settings.PreferredRegion);
35 settings.AppID = EditorGUILayout.TextField("AppId", settings.AppID);
36 settings.Protocol = (ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol", settings.Protocol);
37
38 if (string.IsNullOrEmpty(settings.AppID) || settings.AppID.Equals("master"))
39 {
40 EditorGUILayout.HelpBox("The Photon Cloud needs an AppId (GUID) set.\nYou can find it online in your Dashboard.", MessageType.Warning);
41 }
42 break;
43
44 case ServerSettings.HostingOption.SelfHosted:
45 bool hidePort = false;
46 if (settings.Protocol == ConnectionProtocol.Udp && (settings.ServerPort == 4530 || settings.ServerPort == 0))
47 {
48 settings.ServerPort = 5055;
49 }
50 else if (settings.Protocol == ConnectionProtocol.Tcp && (settings.ServerPort == 5055 || settings.ServerPort == 0))
51 {
52 settings.ServerPort = 4530;
53 }
54 #if RHTTP
55 if (settings.Protocol == ConnectionProtocol.RHttp)
56 {
57 settings.ServerPort = 0;
58 hidePort = true;
59 }
60 #endif
61 settings.ServerAddress = EditorGUILayout.TextField("Server Address", settings.ServerAddress);
62 settings.ServerAddress = settings.ServerAddress.Trim();
63 if (!hidePort)
64 {
65 settings.ServerPort = EditorGUILayout.IntField("Server Port", settings.ServerPort);
66 }
67 settings.Protocol = (ConnectionProtocol)EditorGUILayout.EnumPopup("Protocol", settings.Protocol);
68 settings.AppID = EditorGUILayout.TextField("AppId", settings.AppID);
69 break;
70
71 case ServerSettings.HostingOption.OfflineMode:
72 EditorGUI.indentLevel = 0;
73 EditorGUILayout.HelpBox("In 'Offline Mode', the client does not communicate with a server.\nAll settings are hidden currently.", MessageType.Info);
74 break;
75
76 case ServerSettings.HostingOption.NotSet:
77 EditorGUI.indentLevel = 0;
78 EditorGUILayout.HelpBox("Hosting is 'Not Set'.\nConnectUsingSettings() will not be able to connect.\nSelect another option or run the PUN Wizard.", MessageType.Info);
79 break;
80
81 default:
82 DrawDefaultInspector();
83 break;
84 }
85
86 if (PhotonEditor.CheckPunPlus())
87 {
88 settings.Protocol = ConnectionProtocol.Udp;
89 EditorGUILayout.HelpBox("You seem to use PUN+.\nPUN+ only supports reliable UDP so the protocol is locked.", MessageType.Info);
90 }
91
92 settings.AppID = settings.AppID.Trim();
93
94 EditorGUI.indentLevel = 0;
95 SerializedObject sObj = new SerializedObject(this.target);
96 SerializedProperty sRpcs = sObj.FindProperty("RpcList");
97 EditorGUILayout.PropertyField(sRpcs, true);
98 sObj.ApplyModifiedProperties();
99
100 GUILayout.BeginHorizontal();
101 GUILayout.Space(20);
102 if (GUILayout.Button("Refresh RPCs"))
103 {
104 PhotonEditor.UpdateRpcList();
105 Repaint();
106 }
107 if (GUILayout.Button("Clear RPCs"))
108 {
109 PhotonEditor.ClearRpcList();
110 }
111 if (GUILayout.Button("Log HashCode"))
112 {
113 Debug.Log("RPC-List HashCode: " + RpcListHashCode() + ". Make sure clients that send each other RPCs have the same RPC-List.");
114 }
115 GUILayout.Space(20);
116 GUILayout.EndHorizontal();
117
118 //SerializedProperty sp = serializedObject.FindProperty("RpcList");
119 //EditorGUILayout.PropertyField(sp, true);
120
121 if (GUI.changed)
122 {
123 EditorUtility.SetDirty(target);
124 }
125 }
File name: GuideLayer.cs
Copy
11 public void hideGuide()
12 {
13 gameScreen.showCounter();
14 Data.saveData(Data.KEY_GUIDE, 1);
15 Destroy(gameObject);
16 }
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: NextGuideClickListener.cs
Copy
35 public override void OnTouchUp()
36 {
37 if (InputController.Name != InputNames.DIALOG) return;
38 base.OnTouchUp();
39 guideIndex++;
40 if (guideIndex == 4)
41 {
42 gameObject.transform.parent.gameObject.GetComponent
43 }
44 else
45 {
46 guideObject.GetComponent
47 }
48 }
File name: PauseLayerClickListener.cs
Copy
29 public override void OnTouchUp()
30 {
31 if (InputController.Name != InputNames.DIALOG) return;
32 base.OnTouchUp();
33 switch (buttonIndex)
34 {
35 case 0://music
36 SoundManager.isMusic = !SoundManager.isMusic;
37 pauseLayer.changeSprite(0, SoundManager.isMusic);
38 break;
39 case 1://sound
40 SoundManager.isSound = !SoundManager.isSound;
41 pauseLayer.changeSprite(1, SoundManager.isSound);
42 break;
43 case 2://help
44
45 pauseLayer.gameObject.SetActive(false);
46 gameScreen.guideGame();
47
48 break;
49 case 3://resume
50 gameScreen.resumeGame();
51 break;
52 case 4://restart
53 Application.LoadLevel("GameScreen");
54 break;
55 case 5://menu
56 Application.LoadLevel("MapScreen");
57 SoundManager.LoadBgMusic("Sounds/menu", true);
58 break;
59 }
60 }
File name: ButtonStartClickListener.cs
Copy
31 public override void OnTouchUp()
32 {
33 if (InputController.Name != InputNames.DIALOG) return;
34 base.OnTouchUp();
35 if (Data.getData(Data.KEY_GUIDE) == 0)
36 {
37 gameScreen.guideGame();
38 Destroy(transform.parent.gameObject);
39 }
40 else
41 {
42 InputController.Name = "";
43 //InputController.Name = InputNames.GAMESCREEN;
44 //gameScreen.resumeGame();
45 gameScreen.showCounter();
46 Destroy(transform.parent.gameObject);
47 }
48 }
File name: GameScreen.cs
Copy
619 public void guideGame()
620 {
621 guideLayer = (GameObject)Instantiate(Resources.Load
622 guideLayer.GetComponent
623 }
File name: Data.cs
Copy
14 private static void createData()
15 {
16#if UNITY_EDITOR
17 PlayerPrefs.SetInt(KEY_COIN, 3000000);//GOLD
18 PlayerPrefs.SetInt(KEY_WORLD_MAP, 1);//MAP UNLOCK 1
19 for (int i = 0; i < 4; i++)
20 {
21 PlayerPrefs.SetInt(KEY_LEVEL + i, 15);//LEVEL UNLOCK INSIDE MAP 1
22 }
23 for (int i = 0; i < 60; i++)
24 {
25 PlayerPrefs.SetInt(KEY_STAR + i, 3);//STAR 0
26 }
27#else
28 PlayerPrefs.SetInt(KEY_COIN, 3000);//GOLD 3000
29 PlayerPrefs.SetInt(KEY_WORLD_MAP, 1);//MAP UNLOCK 1
30 for (int i = 0; i < 4; i++)
31 {
32 PlayerPrefs.SetInt(KEY_LEVEL + i, 1);//LEVEL UNLOCK INSIDE MAP 1
33 }
34 for (int i = 0; i < 60; i++)
35 {
36 PlayerPrefs.SetInt(KEY_STAR + i, 0);//STAR 0
37 }
38#endif
39 for (int i = 0; i < 2; i++)
40 for (int j = 0; j < 10; j++)
41 {
42 PlayerPrefs.SetInt(KEY_UPGRADE + i + "" + j, 1);
43 }
44 PlayerPrefs.SetInt(KEY_ANIMAL_UNLOCK + "0", 1);
45 for (int i = 1; i < 10; i ++ )
46 PlayerPrefs.SetInt(KEY_ANIMAL_UNLOCK + i, 0);
47 PlayerPrefs.SetInt(KEY_GUIDE, 0);
48
49 PlayerPrefs.Save();
50 }
File name: ReadmeEditor.cs
Copy
46 static Readme SelectReadme()
47 {
48 var ids = AssetDatabase.FindAssets("Readme t:Readme");
49 if (ids.Length == 1)
50 {
51 var readmeObject = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GUIDToAssetPath(ids[0]));
52
53 Selection.objects = new UnityEngine.Object[]{readmeObject};
54
55 return (Readme)readmeObject;
56 }
57 else
58 {
59 Debug.Log("Couldn't find a readme");
60 return null;
61 }
62 }
Download file with original file name:Guid
Guid 155 lượt xem
Gõ tìm kiếm nhanh...