void OnGUIAvatar(CVRAvatar avatar) { GameObject avatarObject = avatar.gameObject; GUI.enabled = true; EditorGUILayout.InspectorTitlebar(avatarObject.activeInHierarchy, avatarObject); int errors = 0; int overallPolygonsCount = 0; int overallSkinnedMeshRenderer = 0; int overallUniqueMaterials = 0; int overallMissingScripts = 0; foreach (MeshFilter filter in avatar.gameObject.GetComponentsInChildren <MeshFilter>()) { if (filter.sharedMesh != null) { overallPolygonsCount = overallPolygonsCount + filter.sharedMesh.triangles.Length / 3; } } foreach (SkinnedMeshRenderer renderer in avatar.gameObject.GetComponentsInChildren <SkinnedMeshRenderer>()) { overallSkinnedMeshRenderer++; if (renderer.sharedMaterials != null) { overallUniqueMaterials = overallUniqueMaterials + renderer.sharedMaterials.Length; } } overallMissingScripts = CCK_Tools.CleanMissingScripts(CCK_Tools.SearchType.Selection, false, avatarObject); if (overallMissingScripts > 0) { errors++; } //Errors if (overallMissingScripts > 0) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_ERROR_AVATAR_MISSING_SCRIPTS"), MessageType.Error); } var animator = avatar.GetComponent <Animator>(); if (animator == null) { errors++; EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_ERROR_ANIMATOR"), MessageType.Error); } if (animator != null && animator.avatar == null) { //errors++; EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_GENERIC"), MessageType.Warning); } //Warnings if (overallPolygonsCount > 100000) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_POLYGONS").Replace("{X}", overallPolygonsCount.ToString()), MessageType.Warning); } if (overallSkinnedMeshRenderer > 10) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_SKINNED_MESH_RENDERERS").Replace("{X}", overallSkinnedMeshRenderer.ToString()), MessageType.Warning); } if (overallUniqueMaterials > 20) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_MATERIALS").Replace("{X}", overallUniqueMaterials.ToString()), MessageType.Warning); } if (avatar.viewPosition == Vector3.zero) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_VIEWPOINT"), MessageType.Warning); } if (animator != null && animator.avatar != null && !animator.avatar.isHuman) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_NON_HUMANOID"), MessageType.Warning); } var avatarMeshes = getAllAssetMeshesInAvatar(avatarObject); if (CheckForLegacyBlendShapeNormals(avatarMeshes)) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_WARNING_LEGACY_BLENDSHAPES"), MessageType.Warning); if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_FIX_IMPORT_SETTINGS"))) { FixLegacyBlendShapeNormals(avatarMeshes); } } //Info if (overallPolygonsCount >= 50000 && overallPolygonsCount <= 100000) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_INFO_POLYGONS").Replace("{X}", overallPolygonsCount.ToString()), MessageType.Info); } if (overallSkinnedMeshRenderer >= 5 && overallSkinnedMeshRenderer <= 10) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_INFO_SKINNED_MESH_RENDERERS").Replace("{X}", overallSkinnedMeshRenderer.ToString()), MessageType.Info); } if (overallUniqueMaterials >= 10 && overallUniqueMaterials <= 20) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_INFO_MATERIALS").Replace("{X}", overallUniqueMaterials.ToString()), MessageType.Info); } if (avatar.viewPosition.y <= 0.5f) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_INFO_SMALL"), MessageType.Info); } if (avatar.viewPosition.y > 3f) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_INFO_HUGE"), MessageType.Info); } if (errors <= 0) { if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_AVATAR_UPLOAD_BUTTON"))) { CCK_BuildUtility.BuildAndUploadAvatar(avatarObject); } } if (overallMissingScripts > 0) { if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_UTIL_REMOVE_MISSING_SCRIPTS_BUTTON"))) { CCK_Tools.CleanMissingScripts(CCK_Tools.SearchType.Selection, true, avatarObject); } } }
void OnGUISpawnable(CVRSpawnable s) { GameObject spawnableObject = s.gameObject; GUI.enabled = true; EditorGUILayout.InspectorTitlebar(spawnableObject.activeInHierarchy, spawnableObject); int errors = 0; int overallPolygonsCount = 0; int overallSkinnedMeshRenderer = 0; int overallUniqueMaterials = 0; int overallMissingScripts = 0; foreach (MeshFilter filter in s.gameObject.GetComponentsInChildren <MeshFilter>()) { if (filter.sharedMesh != null) { overallPolygonsCount = overallPolygonsCount + filter.sharedMesh.triangles.Length / 3; } } foreach (SkinnedMeshRenderer renderer in s.gameObject.GetComponentsInChildren <SkinnedMeshRenderer>()) { overallSkinnedMeshRenderer++; if (renderer.sharedMaterials != null) { overallUniqueMaterials = overallUniqueMaterials + renderer.sharedMaterials.Length; } } overallMissingScripts = CCK_Tools.CleanMissingScripts(CCK_Tools.SearchType.Selection, false, spawnableObject); if (overallMissingScripts > 0) { errors++; } //Errors if (overallMissingScripts > 0) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_ERROR_MISSING_SCRIPT"), MessageType.Error); } //Warnings if (overallPolygonsCount > 100000) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_WARNING_POLYGONS").Replace("{X}", overallPolygonsCount.ToString()), MessageType.Warning); } if (overallSkinnedMeshRenderer > 10) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_WARNING_SKINNED_MESH_RENDERERS").Replace("{X}", overallSkinnedMeshRenderer.ToString()), MessageType.Warning); } if (overallUniqueMaterials > 20) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_WARNING_MATERIALS").Replace("{X}", overallUniqueMaterials.ToString()), MessageType.Warning); } var spawnableMeshes = getAllAssetMeshesInAvatar(spawnableObject); if (CheckForLegacyBlendShapeNormals(spawnableMeshes)) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_WARNING_LEGACY_BLENDSHAPES"), MessageType.Warning); if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_FIX_IMPORT_SETTINGS"))) { FixLegacyBlendShapeNormals(spawnableMeshes); } } //Info if (overallPolygonsCount >= 50000 && overallPolygonsCount <= 100000) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_INFO_POLYGONS").Replace("{X}", overallPolygonsCount.ToString()), MessageType.Info); } if (overallSkinnedMeshRenderer >= 5 && overallSkinnedMeshRenderer <= 10) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_INFO_SKINNED_MESH_RENDERERS").Replace("{X}", overallSkinnedMeshRenderer.ToString()), MessageType.Info); } if (overallUniqueMaterials >= 10 && overallUniqueMaterials <= 20) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_INFO_MATERIALS").Replace("{X}", overallUniqueMaterials.ToString()), MessageType.Info); } if (errors <= 0 && overallMissingScripts <= 0) { if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_PROPS_UPLOAD_BUTTON"))) { CCK_BuildUtility.BuildAndUploadSpawnable(spawnableObject); } } if (overallMissingScripts > 0) { if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_UTIL_REMOVE_MISSING_SCRIPTS_BUTTON"))) { CCK_Tools.CleanMissingScripts(CCK_Tools.SearchType.Selection, true, spawnableObject); } } }
private void Tab_LoggedIn() { EditorGUILayout.LabelField(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_HEADING_ACCOUNT_INFO"), EditorStyles.boldLabel); EditorGUILayout.Space(); EditorGUILayout.LabelField(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_INFOTEXT_AUTHENTICATED_AS"), _username); EditorGUILayout.LabelField(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_INFOTEXT_USER_RANK"), _apiUserRank); EditorGUILayout.LabelField("CCK version ", CCKVersion); EditorGUILayout.Space(); if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_LOGOUT_BUTTON"))) { bool logout = EditorUtility.DisplayDialog( CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_LOGOUT_DIALOG_TITLE"), CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_LOGOUT_DIALOG_BODY"), CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_LOGOUT_DIALOG_ACCEPT"), CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_LOGOUT_DIALOG_DECLINE")); if (logout) { Logout(); } } EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_INFOTEXT_DOCUMENTATION"), MessageType.Info); if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_HEADING_DOCUMENTATION"))) { Application.OpenURL("https://docs.abinteractive.net"); } EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_WARNING_FEEDBACK"), MessageType.Info); if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_HEADING_FEEDBACK"))) { Application.OpenURL("https://hub.abinteractive.net/feedback"); } EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_WARNING_FOLDERPATH"), MessageType.Warning); EditorGUILayout.Space(); EditorGUILayout.LabelField(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_HEADING_FOUNDCONTENT"), EditorStyles.boldLabel); List <CVRAvatar> avatars = new List <CVRAvatar>(); List <CVRSpawnable> spawnables = new List <CVRSpawnable>(); List <CVRWorld> worlds = new List <CVRWorld>(); foreach (CVRWorld w in Resources.FindObjectsOfTypeAll <CVRWorld>()) { if (w.gameObject.activeInHierarchy) { worlds.Add(w); } } foreach (CVRSpawnable s in Resources.FindObjectsOfTypeAll <CVRSpawnable>()) { if (s.gameObject.activeInHierarchy) { spawnables.Add(s); } } foreach (CVRAvatar a in Resources.FindObjectsOfTypeAll <CVRAvatar>()) { if (a.gameObject.activeInHierarchy) { avatars.Add(a); } } if (worlds.Count <= 0 && avatars.Count > 0 && (Application.unityVersion == supportedUnity || Application.unityVersion == supportedUnityLts)) { if (avatars.Count <= 0) { EditorGUILayout.LabelField(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_UPLOADER_NO_AVATARS_FOUND")); } else { if (avatars.Count > 0) { var counter = 0; scrollPos = EditorGUILayout.BeginScrollView(scrollPos); foreach (CVRAvatar a in avatars) { counter++; EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); GUILayout.Label("Avatar Object #" + counter); OnGUIAvatar(a); } EditorGUILayout.EndScrollView(); } } } if (worlds.Count <= 0 && spawnables.Count > 0 && (Application.unityVersion == supportedUnity || Application.unityVersion == supportedUnityLts)) { if (spawnables.Count <= 0) { EditorGUILayout.LabelField(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_UPLOADER_NO_SPAWNABLES_FOUND")); } else { if (spawnables.Count > 0) { var counter = 0; scrollPos = EditorGUILayout.BeginScrollView(scrollPos); foreach (CVRSpawnable s in spawnables) { counter++; EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); GUILayout.Label("Spawnable Object #" + counter); OnGUISpawnable(s); } EditorGUILayout.EndScrollView(); } } } if (avatars.Count <= 0 && worlds.Count == 1 && (Application.unityVersion == supportedUnity || Application.unityVersion == supportedUnityLts)) { int errors = 0; int overallMissingScripts = 0; overallMissingScripts = CCK_Tools.CleanMissingScripts(CCK_Tools.SearchType.Scene, false, null); if (overallMissingScripts > 0) { errors++; } EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_INFOTEXT_WORLDS_NO_AVATARS"), MessageType.Info); //Error if (overallMissingScripts > 0) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_ERROR_WORLD_MISSING_SCRIPTS"), MessageType.Error); } //Warning if (worlds[0].spawns.Length == 0) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_WORLDS_WARNING_SPAWNPOINT"), MessageType.Warning); } //Info if (worlds[0].referenceCamera == null) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_WORLDS_INFO_REFERENCE_CAMERA"), MessageType.Info); } if (worlds[0].respawnHeightY <= -500) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_WORLDS_INFO_RESPAWN_HEIGHT"), MessageType.Info); } if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_UPLOAD_WORLD_BUTTON")) && errors <= 0) { CCK_BuildUtility.BuildAndUploadMapAsset(EditorSceneManager.GetActiveScene(), worlds[0].gameObject); } if (overallMissingScripts > 0) { if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_UTIL_REMOVE_MISSING_SCRIPTS_BUTTON"))) { CCK_Tools.CleanMissingScripts(CCK_Tools.SearchType.Scene, true, null); } } } if (avatars.Count <= 0 && worlds.Count > 1 && (Application.unityVersion == supportedUnity || Application.unityVersion == supportedUnityLts)) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_WORLDS_ERROR_MULTIPLE_CVR_WORLD"), MessageType.Error); } if (avatars.Count > 0 && worlds.Count > 0 && (Application.unityVersion == supportedUnity || Application.unityVersion == supportedUnityLts)) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_WORLDS_ERROR_WORLD_CONTAINS_AVATAR"), MessageType.Error); } if (avatars.Count <= 0 && worlds.Count <= 0 && (Application.unityVersion == supportedUnity || Application.unityVersion == supportedUnityLts)) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_WORLDS_ERROR_NO_CONTENT"), MessageType.Info); } if ((Application.unityVersion != supportedUnity && Application.unityVersion != supportedUnityLts)) { EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_BUILDPANEL_WORLDS_ERROR_UNITY_UNSUPPORTED"), MessageType.Error); } }