EditorUpdate









How do I use Editor Update
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonEditor.cs Copy
215     static PhotonEditor()
216     {
217         EditorApplication.projectWindowChanged += EditorUpdate;
218         EditorApplication.hierarchyWindowChanged += EditorUpdate;
219         EditorApplication.playmodeStateChanged += PlaymodeStateChanged;
220         EditorApplication.update += OnUpdate;
221
222         WizardIcon = AssetDatabase.LoadAssetAtPath("Assets/Photon Unity Networking/photoncloud-icon.png", typeof(Texture2D)) as Texture2D;
223
224         // to be used in toolbar, the enum needs conversion to string[] being done here, once.
225         Array enumValues = Enum.GetValues(typeof(CloudRegionCode));
226         CloudServerRegionNames = new string[enumValues.Length];
227         for (int i = 0; i < CloudServerRegionNames.Length; i++)
228         {
229             CloudServerRegionNames[i] = enumValues.GetValue(i).ToString();
230             if (CloudServerRegionNames[i].Equals("none"))
231             {
232                 CloudServerRegionNames[i] = PhotonEditor.CurrentLang.BestRegionLabel;
233             }
234         }
235
236         // detect optional packages
237         PhotonEditor.CheckPunPlus();
238
239     }
File name: PhotonEditor.cs Copy
336     // called in editor, opens wizard for initial setup, keeps scene PhotonViews up to date and closes connections when compiling (to avoid issues)
337     private static void EditorUpdate()
338     {
339         if (dontCheckPunSetup || PhotonEditor.Current == null)
340         {
341             return;
342         }
343
344         // serverSetting is null when the file gets deleted. otherwise, the wizard should only run once and only if hosting option is not (yet) set
345         if (!PhotonEditor.Current.DisableAutoOpenWizard && PhotonEditor.Current.HostType == ServerSettings.HostingOption.NotSet)
346         {
347             ShowRegistrationWizard();
348         }
349
350         // Workaround for TCP crash. Plus this surpresses any other recompile errors.
351         if (EditorApplication.isCompiling)
352         {
353             if (PhotonNetwork.connected)
354             {
355                 if (lastWarning > EditorApplication.timeSinceStartup - 3)
356                 {
357                     // Prevent error spam
358                     Debug.LogWarning(CurrentLang.WarningPhotonDisconnect);
359                     lastWarning = EditorApplication.timeSinceStartup;
360                 }
361
362                 PhotonNetwork.Disconnect();
363             }
364         }
365     }

EditorUpdate 138 lượt xem

Gõ tìm kiếm nhanh...