示例#1
0
        public async Task GenerateAsync(CancellationToken cancellationToken = default)
        {
            var tablesTask    = Database.GetAllTables(cancellationToken).ToListAsync(cancellationToken).AsTask();
            var viewsTask     = Database.GetAllViews(cancellationToken).ToListAsync(cancellationToken).AsTask();
            var sequencesTask = Database.GetAllSequences(cancellationToken).ToListAsync(cancellationToken).AsTask();
            var synonymsTask  = Database.GetAllSynonyms(cancellationToken).ToListAsync(cancellationToken).AsTask();
            var routinesTask  = Database.GetAllRoutines(cancellationToken).ToListAsync(cancellationToken).AsTask();

            await Task.WhenAll(tablesTask, viewsTask, sequencesTask, synonymsTask, routinesTask).ConfigureAwait(false);

            var tables = await tablesTask.ConfigureAwait(false);

            var views = await viewsTask.ConfigureAwait(false);

            var sequences = await sequencesTask.ConfigureAwait(false);

            var synonyms = await synonymsTask.ConfigureAwait(false);

            var routines = await routinesTask.ConfigureAwait(false);

            var rowCounts = await GetRowCountsAsync(tables, cancellationToken).ConfigureAwait(false);

            var dbVersion = await Connection.Dialect.GetDatabaseDisplayVersionAsync(Connection, cancellationToken).ConfigureAwait(false);

            var renderers   = GetRenderers(tables, views, sequences, synonyms, routines, rowCounts, dbVersion);
            var renderTasks = renderers.Select(r => r.RenderAsync(cancellationToken)).ToArray();
            await Task.WhenAll(renderTasks).ConfigureAwait(false);

            var assetExporter = new AssetExporter();
            await assetExporter.SaveAssetsAsync(ExportDirectory).ConfigureAwait(false);
        }
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string subPath  = Path.Combine(dirPath, ProjectSettingsName);
            string fileName = $"{EditorBuildSettings.ClassID.ToString()}.asset";
            string filePath = Path.Combine(subPath, fileName);

            if (!DirectoryUtils.Exists(subPath))
            {
                DirectoryUtils.CreateDirectory(subPath);
            }

            BuildSettings       asset  = (BuildSettings)Asset;
            IEnumerable <Scene> scenes = asset.Scenes.Select(t => new Scene(t, container.SceneNameToGUID(t)));

            EditorBuildSettings.Initialize(scenes);
            AssetExporter.Export(container, EditorBuildSettings, filePath);

            fileName = $"{EditorSettings.ClassID.ToString()}.asset";
            filePath = Path.Combine(subPath, fileName);

            AssetExporter.Export(container, EditorSettings, filePath);

            fileName = $"ProjectVersion.txt";
            filePath = Path.Combine(subPath, fileName);

            using (FileStream file = FileUtils.Create(filePath))
            {
                using (StreamWriter writer = new StreamWriter(file))
                {
                    writer.Write("m_EditorVersion: 2017.3.0f3");
                }
            }
            return(true);
        }
示例#3
0
 public static bool ExportSceneResource(string customNamespace = null)
 {
     //IL_0015: Unknown result type (might be due to invalid IL or missing references)
     //IL_004e: Unknown result type (might be due to invalid IL or missing references)
     //IL_005f: Unknown result type (might be due to invalid IL or missing references)
     PipelineManager[] array = Object.FindObjectsOfType <PipelineManager>();
     if (array.Length > 0)
     {
         PipelineManager val = array[0];
         val.contentType = 1;
         if (string.IsNullOrEmpty(val.blueprintId))
         {
             val.AssignId();
         }
         EditorPrefs.SetString("lastBuiltAssetBundleBlueprintID", val.blueprintId);
         EditorUtility.SetDirty(array[0]);
         EditorSceneManager.MarkSceneDirty(val.get_gameObject().get_scene());
         EditorSceneManager.SaveScene(val.get_gameObject().get_scene());
     }
     if (CustomDLLMaker.CustomScriptsAvailable())
     {
         ExportCurrentSceneResourceWithPlugin(customNamespace);
         return(true);
     }
     CustomDLLMaker.ClearSavedPluginPrefs();
     AssetExporter.ExportCurrentSceneResource();
     return(false);
 }
示例#4
0
 private static void ExportSceneAndPrepareForUpload(string customNamespace = null)
 {
     try
     {
         if (shouldBuildUnityPackage)
         {
             AssetExporter.ExportCurrentSceneAsUnityPackage();
         }
         else
         {
             AssetExporter.CleanupUnityPackageExport();
         }
         if (ExportSceneResource(customNamespace))
         {
             if (!APIUser.get_CurrentUser().get_hasScriptingAccess() && CustomDLLMaker.CustomScriptsAvailable())
             {
                 CustomDLLMaker.ClearSavedPluginPrefs();
             }
             EditorAssemblies.AddOnAssemblyReloadCallback("CustomDLLMaker", "Cleanup");
             EditorAssemblies.AddOnAssemblyReloadCallback("VRC_SdkBuilder", "UploadLastExportedSceneBlueprint");
         }
         else
         {
             CustomDLLMaker.ClearSavedPluginPrefs();
             UploadLastExportedSceneBlueprint();
         }
     }
     catch (Exception ex)
     {
         AssetExporter.CleanupTmpFiles();
         EditorAssemblies.ClearAssemblyReloadCallbacks();
         throw ex;
         IL_0083 :;
     }
 }
示例#5
0
            public bool Run(BuildPipeline.BuildContext context)
            {
                var assetEntities = AssetExporter.Export(context);

                if (assetEntities.Count == 0)
                {
                    return(true);
                }

                using (var tmpWorld = new World(AssetsScene.Guid.ToString("N")))
                {
                    // Copy asset entities into temporary world
                    foreach (var pair in assetEntities)
                    {
                        CopyEntity(pair.Value, context.World, tmpWorld);
                    }

                    // Export assets scene
                    var outputFile = context.DataDirectory.GetFile(tmpWorld.Name);
                    if (!ExportWorld(outputFile, context.Project, AssetsScene.Path, tmpWorld))
                    {
                        return(false);
                    }

                    // Update manifest
                    context.Manifest.Add(AssetsScene.Guid, AssetsScene.Path, outputFile.AsEnumerable());
                }

                return(true);
            }
示例#6
0
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string folderPath   = Path.Combine(dirPath, Object.AssetsKeyWord, OcclusionCullingSettings.SceneKeyWord);
            string sceneSubPath = GetSceneName(container);
            string fileName     = $"{sceneSubPath}.unity";
            string filePath     = Path.Combine(folderPath, fileName);

            folderPath = Path.GetDirectoryName(filePath);

            if (!DirectoryUtils.Exists(folderPath))
            {
                DirectoryUtils.CreateVirtualDirectory(folderPath);
            }

            AssetExporter.Export(container, Components, filePath);
            SceneImporter sceneImporter = new SceneImporter();
            Meta          meta          = new Meta(sceneImporter, GUID);

            ExportMeta(container, meta, filePath);

            string sceneName     = Path.GetFileName(sceneSubPath);
            string subFolderPath = Path.Combine(folderPath, sceneName);

            if (OcclusionCullingData != null)
            {
                OcclusionCullingData.Initialize(container, m_occlusionCullingSettings);
                ExportAsset(container, OcclusionCullingData, subFolderPath);
            }

            return(true);
        }
示例#7
0
        public void Process()
        {
            if (executePreview || executePreviousPreview)
            {
                var previous = executePreviousPreview;
                executePreview         = false;
                executePreviousPreview = false;

                if (!VenueSdkTools.ValidateVenue(out errorMessage))
                {
                    Debug.LogError(errorMessage);
                    EditorUtility.DisplayDialog("ClusterVRSDK", errorMessage, "閉じる");
                    return;
                }

                if (!previous)
                {
                    EditorPrefsUtils.PreviousBuildSceneName = dataStore?.SelectVenue?.VenueId?.Value ?? "sceneName";
                    AssetExporter.PreparePreview(EditorPrefsUtils.PreviousBuildSceneName);
                }

                VenueSdkTools.PreviewVenue(EditorPrefsUtils.LastBuildPath, EditorPrefsUtils.PreviousBuildSceneName);

                errorMessage = "";
            }
        }
示例#8
0
    public static void RunLastExportedSceneResource()
    {
        string @string = EditorPrefs.GetString("lastExternalPluginPath");
        string string2 = EditorPrefs.GetString("lastVRCPath");
        bool   flag    = false;

        if (string.IsNullOrEmpty(string2) || (!string.IsNullOrEmpty(string2) && !File.Exists(string2)))
        {
            flag = true;
        }
        else if (CustomDLLMaker.CustomScriptsAvailable() && !string.IsNullOrEmpty(@string) && !File.Exists(@string))
        {
            flag = true;
        }
        if (!flag)
        {
            if (CustomDLLMaker.CustomScriptsAvailable())
            {
                RecompileSceneScripts();
            }
            AssetExporter.RunScene(string2, @string);
        }
        else
        {
            EditorUtility.DisplayDialog("Could not run VRChat scene", "Last built VRChat scene could not be found. Please Test/Compile Full Scene (slow).", "OK");
        }
    }
        public override ExportPointer CreateExportPointer(Object asset, bool isLocal)
        {
            if (isLocal)
            {
                throw new NotSupportedException();
            }

            MonoScript script = m_scripts[asset];

            if (!MonoScript.IsReadAssemblyName(script.File.Version, script.File.Flags) || s_unityEngine.IsMatch(script.AssemblyName))
            {
                if (MonoScript.IsReadNamespace(script.File.Version))
                {
                    int fileID = Compute(script.Namespace, script.ClassName);
                    return(new ExportPointer(fileID, UnityEngineGUID, AssetExporter.ToExportType(asset)));
                }
                else
                {
                    ScriptIdentifier scriptInfo = script.GetScriptID();
                    if (!scriptInfo.IsDefault)
                    {
                        int fileID = Compute(scriptInfo.Namespace, scriptInfo.Name);
                        return(new ExportPointer(fileID, UnityEngineGUID, AssetExporter.ToExportType(asset)));
                    }
                }
            }

            long exportID   = GetExportID(asset);
            GUID uniqueGUID = script.GUID;

            return(new ExportPointer(exportID, uniqueGUID, AssetExporter.ToExportType(asset)));
        }
        public override ExportPointer CreateExportPointer(Object asset, bool isLocal)
        {
            long exportID = GetExportID(asset);

            return(isLocal ?
                   new ExportPointer(exportID) :
                   new ExportPointer(exportID, Asset.GUID, AssetExporter.ToExportType(Asset)));
        }
示例#11
0
        static void BuildScene()
        {
            OpenTargetScene();

            var venueId = GetEnv("VENUE_ID");

            AssetExporter.ExportCurrentSceneResource(venueId, false);

            Debug.Log("Finished Build");
        }
 protected override string ExportInner(ProjectAssetContainer container, string filePath)
 {
     if (m_convert)
     {
         string dirPath  = Path.GetDirectoryName(filePath);
         string fileName = Path.GetFileNameWithoutExtension(filePath);
         filePath = $"{Path.Combine(dirPath, fileName)}.png";
     }
     AssetExporter.Export(container, Asset, filePath);
     return(filePath);
 }
示例#13
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();
 }
        public MetaPtr CreateExportPointer(Object asset, bool isLocal)
        {
            if (isLocal)
            {
                throw new ArgumentException(nameof(isLocal));
            }

            long      exportId = GetExportID(asset);
            AssetType type     = AssetExporter.ToExportType(asset);

            return(new MetaPtr(exportId, UnityGUID.MissingReference, type));
        }
示例#15
0
    protected void Build()
    {
        AssetDatabase.SaveAssets();
        if (this.serializedObject.targetObject)
        {
            AssetExporter.GetShaders();
            AssetExporter.GetPublicAssets();
            AssetExporter.BuildAssetBundles(this.serializedObject.targetObject);

            Selection.activeObject = this.serializedObject.targetObject;
        }
        AssetDatabase.Refresh();
    }
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            if (m_export.Count == 0)
            {
                return(false);
            }

            string scriptFolder = m_export[0].ExportPath;
            string scriptPath   = Path.Combine(dirPath, scriptFolder);

            AssetExporter.Export(container, m_export, scriptPath, OnScriptExported);
            return(true);
        }
示例#17
0
        void Process()
        {
            if (executeUpload)
            {
                executeUpload        = false;
                currentUploadService = null;

                if (!VenueValidator.ValidateVenue(out errorMessage))
                {
                    Debug.LogError(errorMessage);
                    EditorUtility.DisplayDialog("Cluster Creator Kit", errorMessage, "閉じる");
                    return;
                }

                ItemIdAssigner.AssignItemId();
                ItemTemplateIdAssigner.Execute();
                LayerCorrector.CorrectLayer();

                try
                {
                    AssetExporter.ExportCurrentSceneResource(venue.VenueId.Value, false); //Notice UnityPackage が大きくなりすぎてあげれないので一旦やめる
                }
                catch (Exception e)
                {
                    errorMessage = $"現在のSceneのUnityPackage作成時にエラーが発生しました。 {e.Message}";
                    return;
                }

                currentUploadService = new UploadVenueService(
                    userInfo.VerifiedToken,
                    venue,
                    completionResponse =>
                {
                    errorMessage   = "";
                    worldDetailUrl = completionResponse.Url;
                    if (EditorPrefsUtils.OpenWorldManagementPageAfterUpload)
                    {
                        Application.OpenURL(worldManagementUrl);
                    }
                },
                    exception =>
                {
                    Debug.LogException(exception);
                    errorMessage = $"ワールドのアップロードに失敗しました。時間をあけてリトライしてみてください。";
                    EditorWindow.GetWindow <VenueUploadWindow>().Repaint();
                });
                currentUploadService.Run();
                errorMessage = null;
            }
        }
示例#18
0
        protected void ExportAsset(ProjectAssetContainer container, IAssetImporter importer, Object asset, string path, string name)
        {
            if (!DirectoryUtils.Exists(path))
            {
                DirectoryUtils.CreateVirtualDirectory(path);
            }

            string filePath = $"{Path.Combine(path, name)}.{asset.ExportExtension}";

            AssetExporter.Export(container, asset, filePath);
            Meta meta = new Meta(importer, asset.GUID);

            ExportMeta(container, meta, filePath);
        }
        protected override string ExportInner(ProjectAssetContainer container, string filePath)
        {
            AudioClip audioClip = (AudioClip)Asset;

            if (AudioAssetExporter.IsSupported(audioClip))
            {
                string dir     = Path.GetDirectoryName(filePath);
                string newName = $"{Path.GetFileNameWithoutExtension(filePath)}.wav";
                filePath = Path.Combine(dir, newName);
            }

            AssetExporter.Export(container, Asset, filePath);
            return(filePath);
        }
示例#20
0
        protected void ExportAsset(ProjectAssetContainer container, AssetImporter importer, Object asset, string path, string name)
        {
            if (!DirectoryUtils.Exists(path))
            {
                DirectoryUtils.CreateVirtualDirectory(path);
            }

            string fullName   = $"{name}.{GetExportExtension(asset)}";
            string uniqueName = FileUtils.GetUniqueName(path, fullName, FileUtils.MaxFileNameLength - MetaExtension.Length);
            string filePath   = Path.Combine(path, uniqueName);

            AssetExporter.Export(container, asset, filePath);
            Meta meta = new Meta(asset.GUID, importer);

            ExportMeta(container, meta, filePath);
        }
示例#21
0
        public void Process()
        {
            if (dataStore.SelectVenue == null)
            {
                errorMessage = null;
                return;
            }

            if (executeUpload)
            {
                executeUpload        = false;
                currentUploadService = null;

                if (!VenueSdkTools.ValidateVenue(out errorMessage))
                {
                    Debug.LogError(errorMessage);
                    EditorUtility.DisplayDialog("ClusterVRSDK", errorMessage, "閉じる");
                    return;
                }

                try
                {
                    var venue = dataStore.SelectVenue;
                    AssetExporter.ExportCurrentSceneResource(venue.VenueId.Value, false); //Notice UnityPackage が大きくなりすぎてあげれないので一旦やめる
                }
                catch (Exception e)
                {
                    errorMessage = $"現在のSceneのUnityPackage作成時にエラーが発生しました。 {e.Message}";
                    return;
                }

                currentUploadService = new UploadVenueService(
                    dataStore.AccessToken,
                    dataStore.SelectVenue,
                    () => errorMessage = "",
                    exception =>
                {
                    errorMessage = $"会場データのアップロードに失敗しました。リトライしてみてください。 {exception.Message}";
                    EditorWindow.GetWindow <VenueUploadWindow>().Repaint();
                });
                currentUploadService.Run();
                errorMessage = null;
            }
        }
示例#22
0
        public override MetaPtr CreateExportPointer(Object asset, bool isLocal)
        {
            if (isLocal)
            {
                throw new NotSupportedException();
            }

            MonoScript script = m_scripts[asset];

            if (!MonoScript.HasAssemblyName(script.File.Version, script.File.Flags) || s_unityEngine.IsMatch(script.AssemblyName))
            {
                if (MonoScript.HasNamespace(script.File.Version))
                {
                    int fileID = Compute(script.Namespace, script.ClassName);
                    return(new MetaPtr(fileID, UnityEngineGUID, AssetExporter.ToExportType(asset)));
                }
                else
                {
                    ScriptIdentifier scriptInfo = script.GetScriptID();
                    if (!scriptInfo.IsDefault)
                    {
                        int fileID = Compute(scriptInfo.Namespace, scriptInfo.Name);
                        return(new MetaPtr(fileID, UnityEngineGUID, AssetExporter.ToExportType(asset)));
                    }
                }
            }

            if (!AssemblyHash.ContainsKey(script.AssemblyNameOrigin))
            {
                AssemblyHash[script.AssemblyNameOrigin] = GetAssemblyHashGuid(script.AssemblyNameOrigin);
            }

            var scriptKey = $"{script.AssemblyNameOrigin}{script.Namespace}{script.ClassName}";

            if (!ScriptId.ContainsKey(scriptKey))
            {
                ScriptId[scriptKey] = Compute(script.Namespace, script.ClassName);
            }

            return(new MetaPtr(ScriptId[scriptKey], new UnityGUID(AssemblyHash[script.AssemblyNameOrigin]), AssetExporter.ToExportType(asset)));
        }
示例#23
0
 public static void UploadLastExportedSceneBlueprint()
 {
     if (VerifyCredentials())
     {
         string @string = EditorPrefs.GetString("lastExternalPluginPath");
         string text    = WWW.UnEscapeURL(EditorPrefs.GetString("lastVRCPath"));
         if (string.IsNullOrEmpty(text) || (!string.IsNullOrEmpty(text) && !File.Exists(text)) || (CustomDLLMaker.CustomScriptsAvailable() && !string.IsNullOrEmpty(@string) && !File.Exists(@string)))
         {
             EditorUtility.DisplayDialog("Could not run VRChat scene", "Last built VRChat scene could not be found. Please Test/Compile Full Scene (slow).", "OK");
         }
         else
         {
             int num = 0;
             if (ValidationHelpers.CheckIfAssetBundleFileTooLarge(1, text, ref num))
             {
                 EditorUtility.DisplayDialog("Could not publish VRChat scene", ValidationHelpers.GetAssetBundleOverSizeLimitMessage(1, num), "OK");
             }
             else
             {
                 EditorPrefs.SetString("currentBuildingAssetBundlePath", text);
                 if (APIUser.get_CurrentUser().get_hasScriptingAccess() && CustomDLLMaker.CustomScriptsAvailable())
                 {
                     EditorPrefs.SetString("externalPluginPath", @string);
                 }
                 else
                 {
                     CustomDLLMaker.ClearSavedPluginPrefs();
                 }
                 if (shouldBuildUnityPackage)
                 {
                     AssetExporter.ExportCurrentSceneAsUnityPackageIfNotExist();
                 }
                 else
                 {
                     AssetExporter.CleanupUnityPackageExport();
                 }
                 AssetExporter.LaunchSceneBlueprintUploader();
             }
         }
     }
 }
示例#24
0
 public static void ExportSceneResourceAndRun(string customNamespace = null)
 {
     try
     {
         if (ExportSceneResource(customNamespace))
         {
             EditorAssemblies.AddOnAssemblyReloadCallback("VRC.AssetExporter", "RunExportedSceneResourceAndCleanupPlugin");
         }
         else
         {
             AssetExporter.RunExportedSceneResourceAndCleanupPlugin();
         }
     }
     catch (Exception ex)
     {
         AssetExporter.CleanupTmpFiles();
         EditorAssemblies.ClearAssemblyReloadCallbacks();
         throw ex;
         IL_0039 :;
     }
 }
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string folderPath   = Path.Combine(dirPath, Object.AssetsKeyword, OcclusionCullingSettings.SceneKeyword);
            string sceneSubPath = GetSceneName(container);
            string fileName     = $"{sceneSubPath}.unity";
            string filePath     = Path.Combine(folderPath, fileName);

            if (IsDuplicate(container))
            {
                if (FileUtils.Exists(filePath))
                {
                    Logger.Log(LogType.Warning, LogCategory.Export, $"Duplicate scene '{sceneSubPath}' has been found. Skipping");
                    return(false);
                }
            }

            folderPath = Path.GetDirectoryName(filePath);
            if (!DirectoryUtils.Exists(folderPath))
            {
                DirectoryUtils.CreateVirtualDirectory(folderPath);
            }

            AssetExporter.Export(container, Components.Select(t => t.Convert(container)), filePath);
            DefaultImporter sceneImporter = new DefaultImporter(container.ExportLayout);
            Meta            meta          = new Meta(GUID, sceneImporter);

            ExportMeta(container, meta, filePath);

            string sceneName     = Path.GetFileName(sceneSubPath);
            string subFolderPath = Path.Combine(folderPath, sceneName);

            if (OcclusionCullingData != null)
            {
                OcclusionCullingData.Initialize(container, m_occlusionCullingSettings);
                ExportAsset(container, OcclusionCullingData, subFolderPath);
            }

            return(true);
        }
 protected override bool ExportInner(ProjectAssetContainer container, string filePath)
 {
     return(AssetExporter.Export(container, Asset, filePath));
 }
        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();
        }
        private void OnGUISceneCheck(VRC_SceneDescriptor scene)
        {
            CheckUploadChanges(scene);

#if !VRC_SDK_VRCSDK2 && !VRC_SDK_VRCSDK3
            bool isSdk3Scene = false;
#elif VRC_SDK_VRCSDK2 && !VRC_SDK_VRCSDK3
            bool isSdk3Scene = false;
#elif !VRC_SDK_VRCSDK2 && VRC_SDK_VRCSDK3
            bool isSdk3Scene = true; //Do we actually use this variable anywhere?
#else
            bool isSdk3Scene = scene as VRCSceneDescriptor != null;
#endif

            List <VRC_EventHandler> sdkBaseEventHandlers =
                new List <VRC_EventHandler>(Object.FindObjectsOfType <VRC_EventHandler>());
#if VRC_SDK_VRCSDK2
            if (isSdk3Scene == false)
            {
                for (int i = sdkBaseEventHandlers.Count - 1; i >= 0; --i)
                {
                    if (sdkBaseEventHandlers[i] as VRCSDK2.VRC_EventHandler)
                    {
                        sdkBaseEventHandlers.RemoveAt(i);
                    }
                }
            }
#endif
            if (sdkBaseEventHandlers.Count > 0)
            {
                _builder.OnGUIError(scene,
                                    "You have Event Handlers in your scene that are not allowed in this build configuration.",
                                    delegate
                {
                    List <Object> gos = sdkBaseEventHandlers.ConvertAll(item => (Object)item.gameObject);
                    Selection.objects = gos.ToArray();
                },
                                    delegate
                {
                    foreach (VRC_EventHandler eh in sdkBaseEventHandlers)
                    {
#if VRC_SDK_VRCSDK2
                        GameObject go = eh.gameObject;
                        if (isSdk3Scene == false)
                        {
                            if (VRC_SceneDescriptor.Instance as VRCSDK2.VRC_SceneDescriptor != null)
                            {
                                go.AddComponent <VRCSDK2.VRC_EventHandler>();
                            }
                        }
#endif
                        Object.DestroyImmediate(eh);
                    }
                });
            }

            Vector3 g = Physics.gravity;
            if (Math.Abs(g.x) > float.Epsilon || Math.Abs(g.z) > float.Epsilon)
            {
                _builder.OnGUIWarning(scene,
                                      "Gravity vector is not straight down. Though we support different gravity, player orientation is always 'upwards' so things don't always behave as you intend.",
                                      delegate { SettingsService.OpenProjectSettings("Project/Physics"); }, null);
            }
            if (g.y > 0)
            {
                _builder.OnGUIWarning(scene,
                                      "Gravity vector is not straight down, inverted or zero gravity will make walking extremely difficult.",
                                      delegate { SettingsService.OpenProjectSettings("Project/Physics"); }, null);
            }
            if (Math.Abs(g.y) < float.Epsilon)
            {
                _builder.OnGUIWarning(scene,
                                      "Zero gravity will make walking extremely difficult, though we support different gravity, player orientation is always 'upwards' so this may not have the effect you're looking for.",
                                      delegate { SettingsService.OpenProjectSettings("Project/Physics"); }, null);
            }

            if (CheckFogSettings())
            {
                _builder.OnGUIWarning(
                    scene,
                    "Fog shader stripping is set to Custom, this may lead to incorrect or unnecessary shader variants being included in the build. You should use Automatic unless you change the fog mode at runtime.",
                    delegate { SettingsService.OpenProjectSettings("Project/Graphics"); },
                    delegate
                {
                    EnvConfig.SetFogSettings(
                        new EnvConfig.FogSettings(EnvConfig.FogSettings.FogStrippingMode.Automatic));
                });
            }

            if (scene.autoSpatializeAudioSources)
            {
                _builder.OnGUIWarning(scene,
                                      "Your scene previously used the 'Auto Spatialize Audio Sources' feature. This has been deprecated, press 'Fix' to disable. Also, please add VRC_SpatialAudioSource to all your audio sources. Make sure Spatial Blend is set to 3D for the sources you want to spatialize.",
                                      null,
                                      delegate { scene.autoSpatializeAudioSources = false; }
                                      );
            }

            AudioSource[] audioSources = Object.FindObjectsOfType <AudioSource>();
            foreach (AudioSource a in audioSources)
            {
                if (a.GetComponent <ONSPAudioSource>() != null)
                {
                    _builder.OnGUIWarning(scene,
                                          "Found audio source(s) using ONSP, this is deprecated. Press 'fix' to convert to VRC_SpatialAudioSource.",
                                          delegate { Selection.activeObject = a.gameObject; },
                                          delegate
                    {
                        Selection.activeObject = a.gameObject;
                        AutoAddSpatialAudioComponents.ConvertONSPAudioSource(a);
                    }
                                          );
                    break;
                }
                else if (a.GetComponent <VRC_SpatialAudioSource>() == null)
                {
                    string msg =
                        "Found 3D audio source with no VRC Spatial Audio component, this is deprecated. Press 'fix' to add a VRC_SpatialAudioSource.";
                    if (IsAudioSource2D(a))
                    {
                        msg =
                            "Found 2D audio source with no VRC Spatial Audio component, this is deprecated. Press 'fix' to add a (disabled) VRC_SpatialAudioSource.";
                    }

                    _builder.OnGUIWarning(scene, msg,
                                          delegate { Selection.activeObject = a.gameObject; },
                                          delegate
                    {
                        Selection.activeObject = a.gameObject;
                        AutoAddSpatialAudioComponents.AddVRCSpatialToBareAudioSource(a);
                    }
                                          );
                    break;
                }
            }

            if (VRCSdkControlPanel.HasSubstances())
            {
                _builder.OnGUIWarning(scene,
                                      "One or more scene objects have Substance materials. This is not supported and may break in game. Please bake your Substances to regular materials.",
                                      () => { Selection.objects = VRCSdkControlPanel.GetSubstanceObjects(); },
                                      null);
            }

#if VRC_SDK_VRCSDK2
            foreach (VRC_DataStorage ds in Object.FindObjectsOfType <VRC_DataStorage>())
            {
                VRCSDK2.VRC_ObjectSync os = ds.GetComponent <VRCSDK2.VRC_ObjectSync>();
                if (os != null && os.SynchronizePhysics)
                {
                    _builder.OnGUIWarning(scene, ds.name + " has a VRC_DataStorage and VRC_ObjectSync, with SynchronizePhysics enabled.",
                                          delegate { Selection.activeObject = os.gameObject; }, null);
                }
            }
#endif

            string vrcFilePath = UnityWebRequest.UnEscapeURL(EditorPrefs.GetString("lastVRCPath"));
            if (!string.IsNullOrEmpty(vrcFilePath) &&
                ValidationHelpers.CheckIfAssetBundleFileTooLarge(ContentType.World, vrcFilePath, out int fileSize))
            {
                _builder.OnGUIWarning(scene,
                                      ValidationHelpers.GetAssetBundleOverSizeLimitMessageSDKWarning(ContentType.World, fileSize), null,
                                      null);
            }

            foreach (GameObject go in Object.FindObjectsOfType <GameObject>())
            {
                if (go.transform.parent == null)
                {
                    // check root game objects
#if UNITY_ANDROID
                    IEnumerable <Shader> illegalShaders = VRCSDK2.Validation.WorldValidation.FindIllegalShaders(go);
                    foreach (Shader s in illegalShaders)
                    {
                        _builder.OnGUIWarning(scene, "World uses unsupported shader '" + s.name + "'. This could cause low performance or future compatibility issues.", null, null);
                    }
#endif
                }
                else
                {
                    // Check sibling game objects
                    for (int idx = 0; idx < go.transform.parent.childCount; ++idx)
                    {
                        Transform t = go.transform.parent.GetChild(idx);
                        if (t == go.transform)
                        {
                            continue;
                        }

#if VRC_SDK_VRCSDK2
                        bool allowedType = (t.GetComponent <VRCSDK2.VRC_ObjectSync>() ||
                                            t.GetComponent <VRCSDK2.VRC_SyncAnimation>() ||
                                            t.GetComponent <VRC_SyncVideoPlayer>() ||
                                            t.GetComponent <VRC_SyncVideoStream>());
                        if (t.name != go.transform.name || allowedType)
                        {
                            continue;
                        }
#else
                        if (t.name != go.transform.name)
                        {
                            continue;
                        }
#endif

                        string    path = t.name;
                        Transform p    = t.parent;
                        while (p != null)
                        {
                            path = p.name + "/" + path;
                            p    = p.parent;
                        }

                        _builder.OnGUIWarning(scene,
                                              "Sibling objects share the same path, which may break network events: " + path,
                                              delegate
                        {
                            List <Object> gos = new List <Object>();
                            for (int c = 0; c < go.transform.parent.childCount; ++c)
                            {
                                if (go.transform.parent.GetChild(c).name == go.name)
                                {
                                    gos.Add(go.transform.parent.GetChild(c).gameObject);
                                }
                            }
                            Selection.objects = gos.ToArray();
                        },
                                              delegate
                        {
                            List <Object> gos = new List <Object>();
                            for (int c = 0; c < go.transform.parent.childCount; ++c)
                            {
                                if (go.transform.parent.GetChild(c).name == go.name)
                                {
                                    gos.Add(go.transform.parent.GetChild(c).gameObject);
                                }
                            }
                            Selection.objects = gos.ToArray();
                            for (int i = 0; i < gos.Count; ++i)
                            {
                                gos[i].name = gos[i].name + "-" + i.ToString("00");
                            }
                        });
                        break;
                    }
                }
            }

            // detect dynamic materials and prefabs with identical names (since these could break triggers)
            VRC_Trigger[]     triggers  = Tools.FindSceneObjectsOfTypeAll <VRC_Trigger>();
            List <GameObject> prefabs   = new List <GameObject>();
            List <Material>   materials = new List <Material>();

#if VRC_SDK_VRCSDK2
            AssetExporter.FindDynamicContent(ref prefabs, ref materials);
#elif VRC_SDK_VRCSDK3
            AssetExporter.FindDynamicContent(ref prefabs, ref materials);
#endif

            foreach (VRC_Trigger t in triggers)
            {
                foreach (VRC_Trigger.TriggerEvent triggerEvent in t.Triggers)
                {
                    foreach (VRC_EventHandler.VrcEvent e in triggerEvent.Events.Where(evt =>
                                                                                      evt.EventType == VRC_EventHandler.VrcEventType.SpawnObject))
                    {
                        GameObject go =
                            AssetDatabase.LoadAssetAtPath(e.ParameterString, typeof(GameObject)) as GameObject;
                        if (go == null)
                        {
                            continue;
                        }
                        foreach (GameObject existing in prefabs)
                        {
                            if (go == existing || go.name != existing.name)
                            {
                                continue;
                            }
                            _builder.OnGUIWarning(scene,
                                                  "Trigger prefab '" + AssetDatabase.GetAssetPath(go).Replace(".prefab", "") +
                                                  "' has same name as a prefab in another folder. This may break the trigger.",
                                                  delegate { Selection.objects = new Object[] { go }; },
                                                  delegate
                            {
                                AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(go),
                                                          go.name + "-" + go.GetInstanceID());
                                AssetDatabase.Refresh();
                                e.ParameterString = AssetDatabase.GetAssetPath(go);
                            });
                        }
                    }

                    foreach (VRC_EventHandler.VrcEvent e in triggerEvent.Events.Where(evt =>
                                                                                      evt.EventType == VRC_EventHandler.VrcEventType.SetMaterial))
                    {
                        Material mat = AssetDatabase.LoadAssetAtPath <Material>(e.ParameterString);
                        if (mat == null || mat.name.Contains("(Instance)"))
                        {
                            continue;
                        }
                        foreach (Material existing in materials)
                        {
                            if (mat == existing || mat.name != existing.name)
                            {
                                continue;
                            }
                            _builder.OnGUIWarning(scene,
                                                  "Trigger material '" + AssetDatabase.GetAssetPath(mat).Replace(".mat", "") +
                                                  "' has same name as a material in another folder. This may break the trigger.",
                                                  delegate { Selection.objects = new Object[] { mat }; },
                                                  delegate
                            {
                                AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(mat),
                                                          mat.name + "-" + mat.GetInstanceID());
                                AssetDatabase.Refresh();
                                e.ParameterString = AssetDatabase.GetAssetPath(mat);
                            });
                        }
                    }
                }
            }
        }
示例#29
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        GUILayout.Space(50);

        //if (!Role.Skin && Role.BaseLook.Length == 0)
        //    Role.Skin = Role.GetComponentInChildren<SkinnedMeshRenderer>();

        if (GUILayout.Button("Save"))
        {
            AssetDatabase.SaveAssets();
        }

        if (GUILayout.Button("Build"))
        {
            AssetExporter.GetShaders();
            AssetExporter.GetPublicAssets();
            AssetExporter.BuildAssetBundles(this.Role.gameObject);
            Selection.activeObject = this.serializedObject.targetObject;
        }

        if (GUILayout.Button("生成控制器"))
        {
            if (Selection.activeObject != this.Role.gameObject)
            {
                return;
            }
            string rootpath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(Selection.activeObject));
            Selection.activeObject = AssetDatabase.LoadAssetAtPath(rootpath, typeof(Object));

            Object[] clips    = Selection.GetFiltered(typeof(AnimationClip), SelectionMode.DeepAssets);
            Animator animator = this.Role.gameObject.GetComponent <Animator>();
            animator.runtimeAnimatorController = AssetExporter.CreateOverrideController(string.Format("{0}.controller", this.Role.gameObject.name), rootpath, clips);
        }

        if (GUILayout.Button("生成骨骼数据"))
        {
            if (Selection.activeObject != this.Role.gameObject)
            {
                return;
            }
            Transform[]       bones  = this.Role.gameObject.GetComponentsInChildren <Transform>(true);
            List <GameObject> golist = new List <GameObject>();
            for (int i = 0; i < bones.Length; i++)
            {
                golist.Add(bones[i].gameObject);
            }

            this.Role.Bones = golist.ToArray();
        }

        if (GUILayout.Button("复制动画"))
        {
            if (Role != null)
            {
                List <OverrideAnimiClip> list = new List <OverrideAnimiClip>();
                Animator roleAnimator         = Role.GetComponent <Animator>();
                if (roleAnimator == null || !(roleAnimator.runtimeAnimatorController is AnimatorOverrideController) || roleAnimator.avatar == null)
                {
                    return;
                }
                AnimatorOverrideController Controller = roleAnimator.runtimeAnimatorController as AnimatorOverrideController;
                List <KeyValuePair <AnimationClip, AnimationClip> > overrides = new List <KeyValuePair <AnimationClip, AnimationClip> >();
                Controller.GetOverrides(overrides);

                for (int i = 0; i < overrides.Count; i++)
                {
                    KeyValuePair <AnimationClip, AnimationClip> kvp = overrides[i];
                    if (kvp.Value == null)
                    {
                        continue;
                    }
                    list.Add(new OverrideAnimiClip(kvp.Key.name, kvp.Value));
                }
                Role.AnimiClips = list.ToArray();
            }
        }

        if (GUILayout.Button("添加目标"))
        {
            if (!ModelLoader.self)
            {
                return;
            }
            RoleObject target = ModelLoader.CreateRole(this.Role, false);
            target.transform.position = new Vector3(Random.Range(-5, 5), 0, Random.Range(10, 15));
            target.transform.LookAt(ModelLoader.self.transform);
            target.tag     = "target";
            target.enabled = false;

            ModelLoader.targetList.Add(target);
        }

        if (GUILayout.Button("预览低模"))
        {
            if (!EditorApplication.isPlaying)
            {
                EditorUtility.DisplayDialog("Error", "需要在运行状态下才能进行该操作", "OK");
                return;
            }

            ModelLoader.ResetPreviewingObject();

            roleObject = ModelLoader.CreateRole(this.Role, false);

            roleObject.tag               = "self";
            ModelLoader.self             = roleObject;
            ModelLoader.PreviewingObject = roleObject.gameObject;
            ModelLoader.SetupCamera(ModelLoader.PreviewingObject.transform);
            TriangleArea ta = roleObject.gameObject.AddComponent <TriangleArea>();
        }

        if (GUILayout.Button("预览高模"))
        {
            if (!EditorApplication.isPlaying)
            {
                EditorUtility.DisplayDialog("Error", "需要在运行状态下才能进行该操作", "OK");
                return;
            }

            ModelLoader.ResetPreviewingObject();

            roleObject = ModelLoader.CreateRole(this.Role, true);

            roleObject.tag               = "self";
            ModelLoader.self             = roleObject;
            ModelLoader.PreviewingObject = roleObject.gameObject;
            ModelLoader.SetupCamera(ModelLoader.PreviewingObject.transform);
            TriangleArea ta = roleObject.gameObject.AddComponent <TriangleArea>();
        }

        //当Inspector 面板发生变化时保存数据
        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
示例#30
0
        public override bool Export(ProjectAssetContainer container, string dirPath)
        {
            string subPath  = Path.Combine(dirPath, ProjectSettingsName);
            string fileName = $"{EditorBuildSettings.ClassID.ToString()}.asset";
            string filePath = Path.Combine(subPath, fileName);

            if (!DirectoryUtils.Exists(subPath))
            {
                DirectoryUtils.CreateDirectory(subPath);
            }

            BuildSettings       asset  = (BuildSettings)Asset;
            IEnumerable <Scene> scenes = asset.Scenes.Select(t => new Scene(t, container.SceneNameToGUID(t)));

            EditorBuildSettings.Initialize(scenes);
            AssetExporter.Export(container, EditorBuildSettings, filePath);

            fileName = $"{EditorSettings.ClassID.ToString()}.asset";
            filePath = Path.Combine(subPath, fileName);

            AssetExporter.Export(container, EditorSettings, filePath);

            if (NavMeshProjectSettings != null)
            {
                fileName = $"{NavMeshProjectSettings.ExportName}.asset";
                filePath = Path.Combine(subPath, fileName);

                AssetExporter.Export(container, NavMeshProjectSettings, filePath);
            }
            if (NetworkManager != null)
            {
                fileName = $"{NetworkManager.ExportName}.asset";
                filePath = Path.Combine(subPath, fileName);

                AssetExporter.Export(container, NetworkManager, filePath);
            }
            if (Physics2DSettings != null)
            {
                fileName = $"{Physics2DSettings.ExportName}.asset";
                filePath = Path.Combine(subPath, fileName);

                AssetExporter.Export(container, Physics2DSettings, filePath);
            }
            if (UnityConnectSettings != null)
            {
                fileName = $"{UnityConnectSettings.ExportName}.asset";
                filePath = Path.Combine(subPath, fileName);

                AssetExporter.Export(container, UnityConnectSettings, filePath);
            }
            if (QualitySettings != null)
            {
                fileName = $"{QualitySettings.ExportName}.asset";
                filePath = Path.Combine(subPath, fileName);

                AssetExporter.Export(container, QualitySettings, filePath);
            }

            fileName = $"ProjectVersion.txt";
            filePath = Path.Combine(subPath, fileName);

            using (FileStream file = FileUtils.Create(filePath))
            {
                using (StreamWriter writer = new InvariantStreamWriter(file, Encoding.UTF8))
                {
                    writer.Write("m_EditorVersion: 2017.3.0f3");
                }
            }
            return(true);
        }