Ejemplo n.º 1
0
 private void StartPublishing()
 {
     GotoUdonInternalState.Instance.enableAutomaticPublish = true;
     EditorUtility.SetDirty(GotoUdonInternalState.Instance);
     EnvConfig.ConfigurePlayerSettings();
     VRC_SdkBuilder.PreBuildBehaviourPackaging();
     VRC_SdkBuilder.ExportAndUploadSceneBlueprint();
 }
Ejemplo n.º 2
0
 private void BuildAndTest()
 {
     EnvConfig.ConfigurePlayerSettings();
     VRC_SdkBuilder.shouldBuildUnityPackage = false;
     AssetExporter.CleanupUnityPackageExport(); // force unity package rebuild on next publish
     VRC_SdkBuilder.RunSetNumClients(0);
     VRC_SdkBuilder.forceNoVR = true;
     VRC_SdkBuilder.PreBuildBehaviourPackaging();
     VRC_SdkBuilder.RunExportSceneResourceAndRun();
     StartClients();
 }
        void OnGUIScene()
        {
            GUILayout.Label("", VRCSdkControlPanel.scrollViewSeparatorStyle);

            _builderScrollPos = GUILayout.BeginScrollView(_builderScrollPos, false, false, GUIStyle.none,
                                                          GUI.skin.verticalScrollbar, GUILayout.Width(VRCSdkControlPanel.SdkWindowWidth),
                                                          GUILayout.MinHeight(217));

            GUILayout.BeginVertical(VRCSdkControlPanel.boxGuiStyle, GUILayout.Width(VRCSdkControlPanel.SdkWindowWidth));
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical(GUILayout.Width(300));
            EditorGUILayout.Space();
            GUILayout.Label("Local Testing", VRCSdkControlPanel.infoGuiStyle);
            GUILayout.Label(
                "Before uploading your world you may build and test it in the VRChat client. You won't be able to invite anyone from online but you can launch multiple of your own clients.",
                VRCSdkControlPanel.infoGuiStyle);
            GUILayout.EndVertical();
            GUILayout.BeginVertical(GUILayout.Width(200));
            EditorGUILayout.Space();
            _numClients = EditorGUILayout.IntField("Number of Clients", _numClients, GUILayout.MaxWidth(190));
            EditorGUILayout.Space();
            _forceNoVr = EditorGUILayout.Toggle("Force Non-VR", _forceNoVr, GUILayout.MaxWidth(190));
            EditorGUILayout.Space();

            GUI.enabled = _builder.NoGuiErrorsOrIssues();

            string lastUrl = VRC_SdkBuilder.GetLastUrl();

            bool lastBuildPresent = lastUrl != null;

            if (lastBuildPresent == false)
            {
                GUI.enabled = false;
            }
            if (VRCSettings.Get().DisplayAdvancedSettings)
            {
                if (GUILayout.Button("Last Build"))
                {
                    VRC_SdkBuilder.shouldBuildUnityPackage = false;
                    VRC_SdkBuilder.SetNumClients(_numClients);
                    VRC_SdkBuilder.forceNoVR = _forceNoVr;
                    VRC_SdkBuilder.RunLastExportedSceneResource();
                }

                if (Core.APIUser.CurrentUser.hasSuperPowers)
                {
                    if (GUILayout.Button("Copy Test URL"))
                    {
                        TextEditor te = new TextEditor {
                            text = lastUrl
                        };
                        te.SelectAll();
                        te.Copy();
                    }
                }
            }

            GUI.enabled = _builder.NoGuiErrorsOrIssues() ||
                          Core.APIUser.CurrentUser.developerType == Core.APIUser.DeveloperType.Internal;

#if UNITY_ANDROID
            EditorGUI.BeginDisabledGroup(true);
#endif
            if (GUILayout.Button("Build & Test"))
            {
                bool buildTestBlocked = !VRCBuildPipelineCallbacks.OnVRCSDKBuildRequested(VRCSDKRequestedBuildType.Scene);
                if (!buildTestBlocked)
                {
#if VRC_SDK_VRCSDK2
                    EnvConfig.ConfigurePlayerSettings();
                    VRC_SdkBuilder.shouldBuildUnityPackage = false;
                    AssetExporter.CleanupUnityPackageExport(); // force unity package rebuild on next publish
                    VRC_SdkBuilder.SetNumClients(_numClients);
                    VRC_SdkBuilder.forceNoVR = _forceNoVr;
                    VRC_SdkBuilder.PreBuildBehaviourPackaging();
                    VRC_SdkBuilder.ExportSceneResourceAndRun();
#elif VRC_SDK_VRCSDK3
                    EnvConfig.ConfigurePlayerSettings();
                    VRC_SdkBuilder.shouldBuildUnityPackage = false;
                    AssetExporter.CleanupUnityPackageExport(); // force unity package rebuild on next publish
                    VRC_SdkBuilder.SetNumClients(_numClients);
                    VRC_SdkBuilder.forceNoVR = _forceNoVr;
                    VRC_SdkBuilder.PreBuildBehaviourPackaging();
                    VRC_SdkBuilder.ExportSceneResourceAndRun();
#endif
                }
            }
#if UNITY_ANDROID
            EditorGUI.EndDisabledGroup();
#endif

            GUILayout.EndVertical();

            if (Event.current.type != EventType.Used)
            {
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();
                GUILayout.EndVertical();
            }

            EditorGUILayout.Space();

            GUILayout.BeginVertical(VRCSdkControlPanel.boxGuiStyle, GUILayout.Width(VRCSdkControlPanel.SdkWindowWidth));

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical(GUILayout.Width(300));
            EditorGUILayout.Space();
            GUILayout.Label("Online Publishing", VRCSdkControlPanel.infoGuiStyle);
            GUILayout.Label(
                "In order for other people to enter your world in VRChat it must be built and published to our game servers.",
                VRCSdkControlPanel.infoGuiStyle);
            EditorGUILayout.Space();
            GUILayout.EndVertical();
            GUILayout.BeginVertical(GUILayout.Width(200));
            EditorGUILayout.Space();

            if (lastBuildPresent == false)
            {
                GUI.enabled = false;
            }
            if (VRCSettings.Get().DisplayAdvancedSettings)
            {
                if (GUILayout.Button("Last Build"))
                {
                    if (Core.APIUser.CurrentUser.canPublishWorlds)
                    {
                        EditorPrefs.SetBool("VRC.SDKBase_StripAllShaders", false);
                        VRC_SdkBuilder.shouldBuildUnityPackage = VRCSdkControlPanel.FutureProofPublishEnabled;
                        VRC_SdkBuilder.UploadLastExportedSceneBlueprint();
                    }
                    else
                    {
                        VRCSdkControlPanel.ShowContentPublishPermissionsDialog();
                    }
                }
            }

            GUI.enabled = _builder.NoGuiErrorsOrIssues() ||
                          Core.APIUser.CurrentUser.developerType == Core.APIUser.DeveloperType.Internal;
            if (GUILayout.Button(VRCSdkControlPanel.GetBuildAndPublishButtonString()))
            {
                bool buildBlocked = !VRCBuildPipelineCallbacks.OnVRCSDKBuildRequested(VRCSDKRequestedBuildType.Scene);
                if (!buildBlocked)
                {
                    if (Core.APIUser.CurrentUser.canPublishWorlds)
                    {
                        EnvConfig.ConfigurePlayerSettings();
                        EditorPrefs.SetBool("VRC.SDKBase_StripAllShaders", false);

                        VRC_SdkBuilder.shouldBuildUnityPackage = VRCSdkControlPanel.FutureProofPublishEnabled;
                        VRC_SdkBuilder.PreBuildBehaviourPackaging();
                        VRC_SdkBuilder.ExportAndUploadSceneBlueprint();
                    }
                    else
                    {
                        VRCSdkControlPanel.ShowContentPublishPermissionsDialog();
                    }
                }
            }

            GUILayout.EndVertical();
            GUI.enabled = true;

            if (Event.current.type == EventType.Used)
            {
                return;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndScrollView();
        }
Ejemplo n.º 4
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.º 5
0
    void ShowBuildControls()
    {
        if (!checkedForIssues)
        {
            EnvConfig.ConfigurePlayerSettings();
        }

        EditorGUILayout.LabelField("Client Version Date", VRC.Core.SDKClientUtilities.GetTestClientVersionDate());
        EditorGUILayout.LabelField("SDK Version Date", VRC.Core.SDKClientUtilities.GetSDKVersionDate());

/**
 *      // Commented this out 12/12/2017 bc client no longer produces version files, resulting in this warning always appearing - Graham
 *      if (!VRC.Core.SDKClientUtilities.IsClientNewerThanSDK())
 *      {
 *          OnGUIWarning(null, "Your SDK is newer than the VRChat client you're testing with. Some SDK features may not work as expected. You can change VRC clients in VRChat SDK/Settings.");
 *      }
 **/

        if (VRC.Core.RemoteConfig.IsInitialized())
        {
            string sdkUnityVersion = VRC.Core.RemoteConfig.GetString("sdkUnityVersion");
            if (Application.unityVersion != sdkUnityVersion)
            {
                OnGUIWarning(null, "You are not using the recommended Unity version for the VRChat SDK. Content built with this version may not work correctly. Please use Unity " + sdkUnityVersion);
            }
        }

        scenes = (VRCSDK2.VRC_SceneDescriptor[])VRC.Tools.FindSceneObjectsOfTypeAll <VRCSDK2.VRC_SceneDescriptor>();
        List <VRCSDK2.VRC_AvatarDescriptor> allavatars = VRC.Tools.FindSceneObjectsOfTypeAll <VRCSDK2.VRC_AvatarDescriptor>().ToList();

        // select only the active avatars
        avatars = allavatars.Where(av => av.gameObject.activeInHierarchy).ToArray();

        if (scenes.Length > 0 && avatars.Length > 0)
        {
            GameObject[] gos = new GameObject[avatars.Length];
            for (int i = 0; i < avatars.Length; ++i)
            {
                gos[i] = avatars[i].gameObject;
            }
            OnGUIError(null, "a unity scene containing a VRChat Scene Descriptor should not also contain avatars.");
        }
        else if (scenes.Length > 1)
        {
            GameObject[] gos = new GameObject[scenes.Length];
            for (int i = 0; i < scenes.Length; ++i)
            {
                gos[i] = scenes[i].gameObject;
            }
            OnGUIError(null, "a unity scene containing a VRChat Scene Descriptor should only contain one scene descriptor.");
        }
        else if (scenes.Length == 1)
        {
            GUILayout.Label("Scene Options", EditorStyles.boldLabel);
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            EditorGUILayout.Space();
            try
            {
                EditorGUI.BeginChangeCheck();

                if (!checkedForIssues)
                {
                    OnGUISceneCheck(scenes[0]);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(scenes[0]);
                    UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
                }

                OnGUIScene(scenes[0]);
                OnGUIShowIssues(scenes[0]);
            }
            catch (System.Exception)
            {
            }
            EditorGUILayout.EndScrollView();
        }
        else if (avatars.Length > 0)
        {
            GUILayout.Label("Avatar Options", EditorStyles.boldLabel);
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
            foreach (var av in avatars)
            {
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.Space();
                if (!checkedForIssues)
                {
                    OnGUIAvatarCheck(av);
                }

                OnGUIAvatar(av);

                if (EditorGUI.EndChangeCheck())
                {
                    EditorUtility.SetDirty(av);
                    UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
                }
            }
            EditorGUILayout.EndScrollView();
        }
        else
        {
            OnGUIError(null, "Please add a scene descriptor or avatar descriptor to your project.");
        }
        OnGUIShowIssues();
        checkedForIssues = true;
    }
    void OnGUIScene_KawaAlt(VRCSDK2.VRC_SceneDescriptor scene)
    {
        string lastUrl          = VRC_SdkBuilder.GetLastUrl();
        bool   lastBuildPresent = lastUrl != null;

        EditorGUILayout.Space();

        using (new GUILayout.HorizontalScope(boxGuiStyle, GUILayout.Width(this.position.width)))
        {
            using (new GUILayout.VerticalScope())
            {
                GUILayout.Label("Offline Testing", infoGuiStyle);
                numClients = EditorGUILayout.IntField("Number of Clients", numClients);

                var lb_enabled = (GUIErrors.Count == 0 && checkedForIssues) && lastBuildPresent;
                using (new EditorGUI.DisabledScope(!lb_enabled))
                {
                    if (GUILayout.Button("Last Build"))
                    {
                        VRC_SdkBuilder.shouldBuildUnityPackage = false;
                        VRC_SdkBuilder.numClientsToLaunch      = numClients;
                        VRC_SdkBuilder.RunLastExportedSceneResource();
                    }
                    if (GUILayout.Button("Copy Test URL"))
                    {
                        TextEditor te = new TextEditor();
                        te.text = lastUrl;
                        te.SelectAll();
                        te.Copy();
                    }
                }

                var bt_enabled = (GUIErrors.Count == 0 && checkedForIssues) || APIUser.CurrentUser.developerType == APIUser.DeveloperType.Internal;
                using (new EditorGUI.DisabledScope(!bt_enabled))
                {
                    if (GUILayout.Button("Build & Test"))
                    {
                        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(customNamespace);
                    }
                }
            }
            using (var vs2 = new GUILayout.VerticalScope())
            {
                GUILayout.Label("Online Publishing", infoGuiStyle);

                using (new EditorGUI.DisabledScope(!lastBuildPresent))
                {
                    if (GUILayout.Button("Last Build"))
                    {
                        if (APIUser.CurrentUser.canPublishWorlds)
                        {
                            VRC_SdkBuilder.shouldBuildUnityPackage = VRCSdkControlPanel.FutureProofPublishEnabled;
                            VRC_SdkBuilder.UploadLastExportedSceneBlueprint();
                        }
                        else
                        {
                            ShowContentPublishPermissionsDialog();
                        }
                    }
                }

                var bp_nabled = (GUIErrors.Count == 0 && checkedForIssues) || APIUser.CurrentUser.developerType == APIUser.DeveloperType.Internal;
                using (new EditorGUI.DisabledScope(!bp_nabled))
                {
                    if (GUILayout.Button("Build & Publish"))
                    {
                        if (APIUser.CurrentUser.canPublishWorlds)
                        {
                            EnvConfig.ConfigurePlayerSettings();
                            VRC_SdkBuilder.shouldBuildUnityPackage = VRCSdkControlPanel.FutureProofPublishEnabled;
                            VRC_SdkBuilder.PreBuildBehaviourPackaging();
                            VRC_SdkBuilder.ExportAndUploadSceneBlueprint(customNamespace);
                        }
                        else
                        {
                            ShowContentPublishPermissionsDialog();
                        }
                    }
                }
            }
        }
    }