Ejemplo n.º 1
0
        private void LoadUserInfoScreen()
        {
            // Refresh Button
            VRCEUiButton btnRefresh = new VRCEUiButton("refresh", new Vector2(0f, 0f), "Refresh");

            btnRefresh.OnClick += () =>
            {
                if (string.IsNullOrEmpty(PageUserInfo.userIdOfLastUserPageInfoViewed))
                {
                    return;
                }
                string id = PageUserInfo.userIdOfLastUserPageInfoViewed;

                ApiCache.Invalidate <APIUser>(id);
                APIUser.FetchUser(id, user =>
                {
                    PageUserInfo pageUserInfo = VRCEUi.UserInfoScreen.GetComponent <PageUserInfo>();

                    if (pageUserInfo != null)
                    {
                        pageUserInfo.SetupUserInfo(user);
                    }
                },
                                  error =>
                                  VRCModLogger.LogError($"Failed to fetch user of id {id}: {error}"));
            };
            VRCMenuUtilsAPI.AddUserInfoButton(btnRefresh);
        }
Ejemplo n.º 2
0
    void OnGUIScene(VRCSDK2.VRC_SceneDescriptor scene)
    {
        string lastUrl          = VRC_SdkBuilder.GetLastUrl();
        bool   lastBuildPresent = lastUrl != null;

        string worldVersion = "-1";

        PipelineManager[] pms = (PipelineManager[])VRC.Tools.FindSceneObjectsOfTypeAll <PipelineManager>();
        if (pms.Length == 1 && !string.IsNullOrEmpty(pms[0].blueprintId))
        {
            if (scene.apiWorld == null)
            {
                ApiWorld world = API.FromCacheOrNew <ApiWorld>(pms[0].blueprintId);
                world.Fetch(null, false,
                            (c) => scene.apiWorld = c.Model as ApiWorld,
                            (c) =>
                {
                    if (c.Code == 404)
                    {
                        Debug.LogErrorFormat("Could not load world {0} because it didn't exist.", pms[0].blueprintId);
                        ApiCache.Invalidate <ApiWorld>(pms[0].blueprintId);
                    }
                    else
                    {
                        Debug.LogErrorFormat("Could not load world {0} because {1}", pms[0].blueprintId, c.Error);
                    }
                });
                scene.apiWorld = world;
            }
            worldVersion = (scene.apiWorld as ApiWorld).version.ToString();
        }
        EditorGUILayout.LabelField("World Version: " + worldVersion);

        EditorGUILayout.Space();

        if (!UpdateLayers.AreLayersSetup() && GUILayout.Button("Setup Layers for VRChat"))
        {
            bool doIt = EditorUtility.DisplayDialog("Setup Layers for VRChat", "This adds all VRChat layers to your project and pushes any custom layers down the layer list. If you have custom layers assigned to gameObjects, you'll need to reassign them. Are you sure you want to continue?", "Do it!", "Don't do it");
            if (doIt)
            {
                UpdateLayers.SetupEditorLayers();
            }
        }

        if (UpdateLayers.AreLayersSetup() && !UpdateLayers.IsCollisionLayerMatrixSetup() && GUILayout.Button("Setup Collision Layer Matrix for VRChat"))
        {
            bool doIt = EditorUtility.DisplayDialog("Setup Collision Layer Matrix for VRChat", "This will setup the correct physics collisions in the PhysicsManager for VRChat layers. Are you sure you want to continue?", "Do it!", "Don't do it");
            if (doIt)
            {
                UpdateLayers.SetupCollisionLayerMatrix();
            }
        }

        scene.autoSpatializeAudioSources = EditorGUILayout.ToggleLeft("Apply 3D spatialization to AudioSources automatically at runtime (override settings by adding an ONSPAudioSource component to game object)", scene.autoSpatializeAudioSources);
        if (GUILayout.Button("Enable 3D spatialization on all 3D AudioSources in scene now"))
        {
            bool doIt = EditorUtility.DisplayDialog("Enable Spatialization", "This will add an ONSPAudioSource script to every 3D AudioSource in the current scene, and enable default settings for spatialization.  Are you sure you want to continue?", "Do it!", "Don't do it");
            if (doIt)
            {
                if (_EnableSpatialization != null)
                {
                    _EnableSpatialization();
                }
                else
                {
                    Debug.LogError("VrcSdkControlPanel: EnableSpatialization callback not found!");
                }
            }
        }

        GUI.enabled = (GUIErrors.Count == 0 && checkedForIssues);
        EditorGUILayout.Space();
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Test", EditorStyles.boldLabel);
        numClients = EditorGUILayout.IntField("Number of Clients", numClients);
        if (lastBuildPresent == false)
        {
            GUI.enabled = false;
        }
        if (GUILayout.Button("Last Build"))
        {
            VRC_SdkBuilder.shouldBuildUnityPackage = false;
            VRC_SdkBuilder.numClientsToLaunch      = numClients;
            VRC_SdkBuilder.RunLastExportedSceneResource();
        }
        if (APIUser.CurrentUser.hasSuperPowers)
        {
            if (GUILayout.Button("Copy Test URL"))
            {
                TextEditor te = new TextEditor();
                te.text = lastUrl;
                te.SelectAll();
                te.Copy();
            }
        }
        if (lastBuildPresent == false)
        {
            GUI.enabled = true;
        }
        if (GUILayout.Button("New Build"))
        {
            EnvConfig.ConfigurePlayerSettings();
            VRC_SdkBuilder.shouldBuildUnityPackage = false;
            VRC.AssetExporter.CleanupUnityPackageExport();  // force unity package rebuild on next publish
            VRC_SdkBuilder.numClientsToLaunch = numClients;
            VRC_SdkBuilder.PreBuildBehaviourPackaging();
            VRC_SdkBuilder.ExportSceneResourceAndRun();
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.Space();
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Publish", EditorStyles.boldLabel);
        if (lastBuildPresent == false)
        {
            GUI.enabled = false;
        }
        if (GUILayout.Button("Last Build"))
        {
            if (APIUser.CurrentUser.canPublishWorlds)
            {
                VRC_SdkBuilder.shouldBuildUnityPackage = VRC.AccountEditorWindow.FutureProofPublishEnabled;
                VRC_SdkBuilder.UploadLastExportedSceneBlueprint();
            }
            else
            {
                ShowContentPublishPermissionsDialog();
            }
        }
        if (lastBuildPresent == false)
        {
            GUI.enabled = true;
        }
        if (GUILayout.Button("New Build"))
        {
            if (APIUser.CurrentUser.canPublishWorlds)
            {
                EnvConfig.ConfigurePlayerSettings();
                VRC_SdkBuilder.shouldBuildUnityPackage = VRC.AccountEditorWindow.FutureProofPublishEnabled;
                VRC_SdkBuilder.PreBuildBehaviourPackaging();
                VRC_SdkBuilder.ExportAndUploadSceneBlueprint();
            }
            else
            {
                ShowContentPublishPermissionsDialog();
            }
        }
        EditorGUILayout.EndVertical();
        GUI.enabled = true;
    }
Ejemplo n.º 3
0
        private void AddUserInfoButtons()
        {
            if (VRCEUi.UserInfoScreen == null)
            {
                ExtendedLogger.LogError("Failed to find UserInfo screen!");
                return;
            }

            Transform btnPlaylists = VRCEUi.InternalUserInfoScreen.PlaylistsButton;
            Transform btnFavorite  = VRCEUi.InternalUserInfoScreen.FavoriteButton;
            Transform btnReport    = VRCEUi.InternalUserInfoScreen.ReportButton;

            if (btnPlaylists == null || btnFavorite == null || btnReport == null)
            {
                ExtendedLogger.LogError("Failed to get required button!");
                return;
            }
            Vector3 pos = btnPlaylists.GetComponent <RectTransform>().localPosition;

            UserInfoLastLogin = new VRCEUiText("LastLoginText", new Vector2(-470f, -130f), "", VRCEUi.UserInfoScreen.transform);
            UserInfoLastLogin.Text.fontSize -= 20;

            UserInfoMore = new VRCEUiButton("More", new Vector2(pos.x, pos.y + 75f), "More", VRCEUi.InternalUserInfoScreen.UserPanel);
            UserInfoMore.Button.onClick.AddListener(() =>
            {
                if (Patch_PageUserInfo.SelectedAPI == null)
                {
                    return;
                }
                ToggleUserInfoMore(UserInfoMore.Text.text == "More");
            });

            UserInfoColliderControl = new VRCEUiButton("ColliderControl", new Vector2(pos.x, pos.y - 75f), "Not in world!", VRCEUi.InternalUserInfoScreen.UserPanel);
            UserInfoColliderControl.Control.gameObject.SetActive(false);
            UserInfoColliderControl.Button.onClick.AddListener(() =>
            {
                if (Patch_PageUserInfo.SelectedAPI == null)
                {
                    return;
                }
                ExtendedUser user = ExtendedServer.Users.FirstOrDefault(a => a.APIUser.id == Patch_PageUserInfo.SelectedAPI.id);

                if (user == null)
                {
                    return;
                }
                user.HasColliders = !user.HasColliders;
                UserInfoColliderControl.Text.text = (user.HasColliders ? "Disable colliders" : "Enable colliders");
            });

            UserInfoRefresh = new VRCEUiButton("Refresh", new Vector2(pos.x, pos.y), "Refresh", VRCEUi.InternalUserInfoScreen.UserPanel);
            UserInfoRefresh.Control.gameObject.SetActive(false);
            UserInfoRefresh.Button.onClick.AddListener(() =>
            {
                if (Patch_PageUserInfo.SelectedAPI == null)
                {
                    return;
                }

                ApiCache.Invalidate <APIUser>(Patch_PageUserInfo.SelectedAPI.id);
                APIUser.FetchUser(Patch_PageUserInfo.SelectedAPI.id, (APIUser user) =>
                {
                    PageUserInfo pageUserInfo = VRCEUi.UserInfoScreen.GetComponent <PageUserInfo>();
                    if (pageUserInfo != null)
                    {
                        pageUserInfo.SetupUserInfo(user);
                    }
                },
                                  (string error) =>
                {
                    ExtendedLogger.LogError(error);
                });
            });
            ExtendedLogger.Log("Setup PageUserInfo!");
        }