private static void TagsDialog(SimulatedVRCPlayer player)
        {
            Dictionary <string, string> tags = player.GetRawTags();

            if (tags.Count > 0)
            {
                SimpleGUI.IndentWithHeader(
                    () => GUILayout.Label("Tags: "),
                    () =>
                {
                    foreach (string key in new List <string>(tags.Keys))
                    {
                        GUILayout.BeginHorizontal();
                        tags[key] = EditorGUILayout.TextField(key, tags[key]);
                        SimpleGUI.ActionButton("X", () => tags.Remove(key), GUILayout.MaxWidth(30));
                        GUILayout.EndHorizontal();
                    }
                }
                    );
            }

            GUILayout.BeginHorizontal();
            string tagName  = player.SetMetadata <string>("tagName", oldName => EditorGUILayout.TextField(oldName));
            string tagValue = player.SetMetadata <string>("tagValue", oldName => EditorGUILayout.TextField(oldName));

            SimpleGUI.ActionButton("Add tag", () => tags[tagName] = tagValue);
            GUILayout.EndHorizontal();
        }
        public static void DrawActiveRuntimePlayer(VRCEmulator emulator, SimulatedVRCPlayer player)
        {
            DrawRuntimePlayer(player);
            GUILayout.BeginHorizontal();
            if (emulator.GetAmountOfPlayers() > 1)
            {
                SimpleGUI.ActionButton("Disconnect", () => emulator.RemovePlayer(player));
            }

            if (!player.IsUsingVR())
            {
                SimpleGUI.ActionButton("Make VR", player.PromoteToVRUser);
            }
            else
            {
                SimpleGUI.ActionButton("Make Desktop", player.DemoteToDesktopUser);
            }

            SimpleGUI.ActionButton("Make Master", () => emulator.MakeMaster(player));
            SimpleGUI.ActionButton("Make Local", () => emulator.MakeLocal(player));
            GUILayout.EndHorizontal();

            SimpleGUI.DrawFoldout(player, "More settings", () =>
            {
                AvatarChangeDialog(player);
                TagsDialog(player);
            });
        }
示例#3
0
        private void DrawClientSection()
        {
            DrawClientSettingsList(_settings.clients);

            SimpleGUI.SectionSpacing();

            if (SimpleGUI.ErrorBox(_settings.WorldId == null, "Can't start clients, missing WorldID"))
            {
                return;
            }

            if (SimpleGUI.ErrorBox(_settings.userId == null, "Can't find user id, please log in SDK."))
            {
                return;
            }

            if (SimpleGUI.ErrorBox(!_settings.IsGamePathValid(), "Can't find game executable"))
            {
                return;
            }

            if (!_localTesting)
            {
                _keepInstance = EditorGUILayout.Toggle("Keep current instance ID", _keepInstance);
            }

            _localTesting = EditorGUILayout.Toggle("Use local testing", _localTesting);
            _clientsManager.InstanceId = EditorGUILayout.TextField(_clientsManager.InstanceId);

            GUILayout.BeginHorizontal();
            string startButtonText = _localTesting ? "Start last version (no build)" : "Start";

            SimpleGUI.ActionButton(startButtonText,
                                   () => _clientsManager.StartClients(false, _keepInstance, _localTesting, _keepInstanceForce));
            if (ClientProcessesManager.IsAnyRunning())
            {
                SimpleGUI.ActionButton("Restart",
                                       () => _clientsManager.StartClients(true, _keepInstance, _localTesting, _keepInstanceForce));
            }
            GUILayout.EndHorizontal();

            if (!Application.isPlaying)
            {
                if (_localTesting)
                {
                    SimpleGUI.ActionButton("Build & Start", BuildAndTest);
                }
                else
                {
                    if (SimpleGUI.ErrorBox(APIUser.CurrentUser == null || !VRC_SdkBuilder.VerifyCredentials(), "Can't find user for auto publish, please log in SDK."))
                    {
                        return;
                    }

                    SimpleGUI.ActionButton("Build & Auto Publish & Start", PublishAndTest);
                }
            }
        }
        private static void AvatarChangeDialog(SimulatedVRCPlayer player)
        {
            GameObject avatar = player.SetMetadata <GameObject>("avatar",
                                                                oldValue => SimpleGUI.ObjectField("Avatar", oldValue, false));

            if (avatar != null)
            {
                SimpleGUI.ActionButton("Change Avatar", () => player.ChangeAvatar(avatar));
            }
        }
示例#5
0
        private bool DrawClientSettings(ClientSettings settings, string buttonAction)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Name", GUILayout.Width(35));
            settings.name = EditorGUILayout.TextField(settings.name, GUILayout.Width(100), GUILayout.ExpandWidth(true));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Profile", GUILayout.Width(45));
            settings.profile = EditorGUILayout.IntField(settings.profile, GUILayout.Width(20));
            if (_localTesting)
            {
                GUILayout.Label("Num of", GUILayout.Width(45));
                settings.instances = EditorGUILayout.IntField(settings.instances, GUILayout.Width(20));
            }

            GUILayout.Label("Enabled", GUILayout.Width(55));
            settings.enabled = EditorGUILayout.Toggle(settings.enabled, GUILayout.Width(15));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
            GUILayout.Label("VR", GUILayout.Width(20));
            settings.vr = EditorGUILayout.Toggle(settings.vr, GUILayout.Width(15));

            bool isRunning = ClientProcessesManager.IsAnyRunning(settings.profile);

            if (isRunning)
            {
                SimpleGUI.ActionButton("Stop All", () => ClientProcessesManager.KillProfile(settings.profile), GUILayout.Width(65));
                SimpleGUI.ActionButton("Restart All",
                                       () =>
                {
                    ClientProcessesManager.KillProfile(settings.profile);
                    _clientsManager.StartClients(_keepInstance, _keepInstanceForce, _localTesting, settings);
                },
                                       GUILayout.Width(90));
            }

            if (_localTesting || !isRunning)
            {
                SimpleGUI.ActionButton("Start One",
                                       () => _clientsManager.StartClients(_keepInstance, _keepInstanceForce, _localTesting, settings.WithInstances(1)),
                                       GUILayout.Width(80));
            }

            bool actionButton = GUILayout.Button(buttonAction, GUILayout.Width(70));

            EditorGUILayout.EndHorizontal();

            return(actionButton);
        }
示例#6
0
 private void DrawAddPlayerBox()
 {
     if (_currentlyEdited == null || (_currentlyEdited.playerName == "" && _currentlyEdited.customId == 0))
     {
         _currentlyEdited = PlayerTemplate.CreateNewPlayer(true);
     }
     PlayerTemplateEditor.DrawPlayerTemplate(_currentlyEdited);
     SimpleGUI.ActionButton("Add player", () =>
     {
         _controller.Emulator.SpawnPlayer(GotoUdonSettings.Instance, _currentlyEdited);
         _currentlyEdited = PlayerTemplate.CreateNewPlayer(true);
     });
 }
示例#7
0
        private void DrawClientSettingsList(List <ClientSettings> allClients)
        {
            ClientSettings removed    = null;
            int            maxProfile = 10;

            foreach (ClientSettings clientSettings in allClients)
            {
                if (clientSettings.profile > maxProfile)
                {
                    maxProfile = clientSettings.profile;
                }
                bool beforeVr = clientSettings.vr;
                if (DrawClientSettings(clientSettings, "Remove"))
                {
                    removed = clientSettings;
                }

                if (!beforeVr && clientSettings.vr)
                {
                    allClients.ForEach(client =>
                    {
                        if (client != clientSettings)
                        {
                            client.vr = false;
                        }
                    });
                }

                SimpleGUI.OptionSpacing();
            }

            if (removed != null)
            {
                allClients.Remove(removed);
            }

            SimpleGUI.ActionButton("Add client", () =>
            {
                allClients.Add(new ClientSettings()
                {
                    name      = "",
                    profile   = maxProfile + 1,
                    instances = 1,
                    enabled   = true
                });
            });
        }
示例#8
0
        internal void DrawVersionInformation()
        {
            DrawSdkUpdateComponent();
            string version               = GotoUdonEditor.VERSION;
            string sdkVersion            = GotoUdonEditor.CurrentSDKVersion;
            string recommendedSdkVersion = GotoUdonEditor.ImplementedSDKVersion;
            string versionString         = sdkVersion == recommendedSdkVersion
                ? $"GotoUdon {version} for SDK {recommendedSdkVersion}"
                : $"GotoUdon {version} for SDK {recommendedSdkVersion}, running on SDK {sdkVersion}";
            string githubUrl = "https://github.com/GotoFinal/GotoUdon/releases";

            if (_updateCheckerLibraryResponse != null)
            {
                if (SimpleGUI.WarningBox(_updateCheckerLibraryResponse.IsError, _updateCheckerLibraryResponse.Error))
                {
                    if (GUILayout.Button($"{versionString}. Click to check for new version at: {githubUrl}",
                                         EditorStyles.helpBox))
                    {
                        Application.OpenURL(githubUrl);
                    }

                    return;
                }

                ReleaseInfo releaseInfo = _updateCheckerLibraryResponse.ReleaseInfo;
                if (releaseInfo.UnityPackage != null && SimpleGUI.InfoBox(releaseInfo.IsNewerThan(version),
                                                                          $"There is new version available: {releaseInfo.Version}! Click to update!\n{releaseInfo.Name}\n{releaseInfo.Description}")
                    )
                {
                    GUILayout.BeginHorizontal();
                    if (!_downloadingUpdate)
                    {
                        SimpleGUI.ActionButton($"Update to {releaseInfo.Version}!", UpdateLibrary);
                    }
                    SimpleGUI.ActionButton("Download manually.", () => Application.OpenURL(releaseInfo.UnityPackage.DownloadUrl));
                    GUILayout.EndHorizontal();
                    return;
                }
            }

            if (GUILayout.Button($"{versionString}. Click to retry check for new version.", EditorStyles.helpBox))
            {
                ForceCheckForUpdate();
            }
        }
示例#9
0
        private void DrawSdkUpdateComponent()
        {
            if (_updateCheckerSdkResponse != null)
            {
                if (_updateCheckerSdkResponse.IsError)
                {
#if GOTOUDON_DEV
                    SimpleGUI.ErrorBox(_updateCheckerSdkResponse.IsError, "Failed to check for VRChat SDK update.");
#endif
                    return;
                }

                ReleaseInfo releaseInfo = _updateCheckerSdkResponse.ReleaseInfo;
                if (releaseInfo.Version == null)
                {
                    return;
                }
                string newestSdkVersion  = NormalizeVrChatSDKVersion(releaseInfo.Version);
                string currentSdkVersion = NormalizeVrChatSDKVersion(GotoUdonEditor.CurrentSDKVersion);

                // I give up, TODO: save version in own repository instead of using vrchat
                if (currentSdkVersion.EndsWith("05.06") && newestSdkVersion.EndsWith("05.12"))
                {
                    return;
                }
                if (releaseInfo.Version.StartsWith(GotoUdonEditor.ImplementedSDKVersion))
                {
                    return;
                }

                if (releaseInfo.UnityPackage != null &&
                    SimpleGUI.InfoBox(
                        VersionUtils.IsRightNewerThanLeft(currentSdkVersion, newestSdkVersion),
                        $"There is new VRChat UDON SDK version available: {releaseInfo.Version}!\n{releaseInfo.Name}\n{releaseInfo.Description}")
                    )
                {
                    GUILayout.BeginHorizontal();
                    // if (!_downloadingSdk)
                    //     SimpleGUI.ActionButton($"Update to {releaseInfo.Version}!", UpdateSdk);
                    SimpleGUI.ActionButton("Download manually.", () => Application.OpenURL(releaseInfo.UnityPackage.DownloadUrl));
                    GUILayout.EndHorizontal();
                }
            }
        }
示例#10
0
    private void DrawTemplatesEditor()
    {
        EditorGUI.BeginChangeCheck();
        DrawGlobalOptions(GotoUdonSettings.Instance);
        SimpleGUI.SectionSpacing();

#if GOTOUDON_SIMULATION_LEGACY
        List <PlayerTemplate> templates = GotoUdonSettings.Instance.playerTemplates;
        if (templates.Count == 0)
        {
            templates.Add(PlayerTemplate.CreateNewPlayer(true));
        }

        GUILayout.Label("Players to create at startup:");
        PlayerTemplate toRemove = null;
        foreach (var template in templates)
        {
            if (PlayerTemplateEditor.DrawPlayerTemplateWithRemoveButton(template))
            {
                toRemove = template;
            }
            SimpleGUI.OptionSpacing();
        }

        templates.Remove(toRemove);
        if (templates.Count == 0)
        {
            templates.Add(PlayerTemplate.CreateNewPlayer(true));
        }

        SimpleGUI.ActionButton("Add another player",
                               () => templates.Add(PlayerTemplate.CreateNewPlayer(templates.Count == 0)));
        SimpleGUI.SectionSpacing();

        if (SimpleGUI.EndChangeCheck())
        {
            EditorUtility.SetDirty(GotoUdonSettings.Instance);
        }

        SimpleGUI.InfoBox(true, "In play mode you will be able to control all created players here, or add more");
#endif
    }
示例#11
0
    private void DrawGlobalOptions(GotoUdonSettings settings)
    {
        settings.Init();
        if (!settings.IsSimulatorInstalled)
        {
            SimpleGUI.ActionButton("Install legacy simulator (probably doesnt work)", () => settings.IsSimulatorInstalled = true);
        }
        else
        {
            SimpleGUI.ActionButton("Remove simulator", () => settings.IsSimulatorInstalled = false);
        }

#if GOTOUDON_SIMULATION_LEGACY
        SimpleGUI.ErrorBox(settings.avatarPrefab == null,
                           "You need to select some avatar prefab to use this resource. You can find ybot-mini in Assets folder with this resource.");
        SimpleGUI.ErrorBox(settings.spawnPoint == null,
                           "You need to select some spawn point to use this resource!");

        GUILayout.Label("Global settings");
        SimpleGUI.Indent(() =>
        {
            settings.enableSimulation = EditorGUILayout.Toggle("Enable simulation", settings.enableSimulation);
            settings.avatarPrefab     = SimpleGUI.ObjectField("Avatar prefab", settings.avatarPrefab, false);
            settings.spawnPoint       = SimpleGUI.ObjectField("Spawn point", settings.spawnPoint, true);
        });

        // nah, not really working
        // SimpleGUI.DrawFoldout(this, "Advanced settings", () =>
        // {
        //     SimpleGUI.WarningBox(true,
        //         "Enabling vrchat client mode might cause some issues, but also allow to test your scripts with secure heap enabled\n" +
        //         "This will add or remove VRC_CLIENT define for compiler, meaning that all internal sdk code will think its running on client and not in editor.\n" +
        //         "Use at own risk.");
        //     string VRC_CLIENT = "VRC_CLIENT";
        //     bool vrchatClientMode = UnityCompilerUtils.IsDefineEnabled(VRC_CLIENT);
        //     string buttonName = vrchatClientMode ? "Use vrchat editor mode" : "Use vrchat client mode";
        //     SimpleGUI.ActionButton(buttonName, () => UnityCompilerUtils.SetDefineEnabled(VRC_CLIENT, !vrchatClientMode));
        // });
#endif
    }
示例#12
0
        public static void DrawReleaseHelper()
        {
#if GOTOUDON_DEV
            SimpleGUI.ActionButton($"Package GotoUdon-{Version}", PrepareRelease);
        }
示例#13
0
 public static void DrawAvailableRuntimePlayer(VRCEmulator emulator, SimulatedVRCPlayer player)
 {
     DrawRuntimePlayer(player);
     SimpleGUI.ActionButton("Connect", () => emulator.AddPlayer(player));
 }