Beispiel #1
0
        private static void ProcessResourceAsset(string assetGuid, string path, Object asset, ProjectResources projectResources)
        {
            if (projectResources.ResourcePaths.Contains(path))                     // Handle assets stored in `Resources`.
            {
                var otherAsset = Resources.Load(path, typeof(UnityEngine.Object)); // Check if a different asset is available under the same resources path.
                if (ObjectUtils.IsValid(otherAsset) && otherAsset != asset)
                {
                    var otherPath = AssetDatabase.GetAssetPath(otherAsset);
                    PostprocessBuild();
                    EditorUtility.ClearProgressBar();
                    throw new System.Exception($"Resource conflict detected: asset stored at `{otherPath}` conflicts with `{path}` Naninovel resource; rename or move the conflicting asset and rebuild the player.");
                }
                return;
            }

            if (useAddressables)
            {
                if (!AddressableHelper.CheckAssetConflict(assetGuid, path, out var conflictAddress))
                {
                    AddressableHelper.CreateOrUpdateAddressableEntry(assetGuid, path);
                    return;
                }
                Debug.Log($"Asset assigned as a Naninovel `{path}` resource is already registered in the Addressable Asset System as `{conflictAddress}`. It will be copied to prevent conflicts.");
            }

            var objPath      = AssetDatabase.GetAssetPath(asset);
            var resourcePath = string.IsNullOrWhiteSpace(config.ProjectRootPath) ? PathUtils.Combine(TempResourcesPath, path) : PathUtils.Combine(TempResourcesPath, config.ProjectRootPath, path);

            if (objPath.Contains("."))
            {
                resourcePath += $".{objPath.GetAfter(".")}";
            }

            EditorUtils.CreateFolderAsset(resourcePath.GetBeforeLast("/"));
            AssetDatabase.CopyAsset(objPath, resourcePath);
        }
        static ScriptView()
        {
            var styleSheetPath = PathUtils.AbsoluteToAssetPath(PathUtils.Combine(PackagePath.EditorResourcesPath, "ScriptEditor.uss"));

            StyleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>(styleSheetPath);
        }
Beispiel #3
0
        private static void CreateResourceCopy(string resourcePath, string copyName)
        {
            var assetPath = PathUtils.AbsoluteToAssetPath(PathUtils.Combine(PackagePath.RuntimeResourcesPath, $"{resourcePath}.prefab"));

            CreateAssetCopy(assetPath, copyName);
        }
Beispiel #4
0
        private static void CreatePrefabCopy(string prefabPath, string copyName)
        {
            var assetPath = PathUtils.AbsoluteToAssetPath(PathUtils.Combine(PackagePath.PrefabsPath, $"{prefabPath}.prefab"));

            CreateAssetCopy(assetPath, copyName);
        }
Beispiel #5
0
        private void AddBuiltinAssets()
        {
            var config = default(ActorManagerConfiguration);

            config = ConfigurationSettings.LoadOrDefaultAndSave <TextPrintersConfiguration>();
            AddActorAsset(config, "Prefabs/TextPrinters/Dialogue.prefab");
            AddActorAsset(config, "Prefabs/TextPrinters/Fullscreen.prefab");
            AddActorAsset(config, "Prefabs/TextPrinters/Wide.prefab");
            AddActorAsset(config, "Prefabs/TextPrinters/Chat.prefab");
            AddActorAsset(config, "Prefabs/TextPrinters/Bubble.prefab");
            AddActorAsset(config, "Prefabs/TextPrinters/TMProDialogue.prefab");
            AddActorAsset(config, "Prefabs/TextPrinters/TMProFullscreen.prefab");
            AddActorAsset(config, "Prefabs/TextPrinters/TMProWide.prefab");
            AddActorAsset(config, "Prefabs/TextPrinters/TMProBubble.prefab");

            config = ConfigurationSettings.LoadOrDefaultAndSave <ChoiceHandlersConfiguration>();
            AddActorAsset(config, "Prefabs/ChoiceHandlers/ButtonList.prefab");
            AddActorAsset(config, "Prefabs/ChoiceHandlers/ButtonArea.prefab");

            AddAsset(SpawnConfiguration.DefaultPathPrefix, "Prefabs/FX/Animate.prefab");
            AddAsset(SpawnConfiguration.DefaultPathPrefix, "Prefabs/FX/DepthOfField.prefab");
            AddAsset(SpawnConfiguration.DefaultPathPrefix, "Prefabs/FX/DigitalGlitch.prefab");
            AddAsset(SpawnConfiguration.DefaultPathPrefix, "Prefabs/FX/Rain.prefab");
            AddAsset(SpawnConfiguration.DefaultPathPrefix, "Prefabs/FX/ShakeBackground.prefab");
            AddAsset(SpawnConfiguration.DefaultPathPrefix, "Prefabs/FX/ShakeCamera.prefab");
            AddAsset(SpawnConfiguration.DefaultPathPrefix, "Prefabs/FX/ShakeCharacter.prefab");
            AddAsset(SpawnConfiguration.DefaultPathPrefix, "Prefabs/FX/ShakePrinter.prefab");
            AddAsset(SpawnConfiguration.DefaultPathPrefix, "Prefabs/FX/Snow.prefab");
            AddAsset(SpawnConfiguration.DefaultPathPrefix, "Prefabs/FX/SunShafts.prefab");

            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/ClickThroughPanel.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/BacklogUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/CGGalleryUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/ConfirmationUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/ContinueInputUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/ExternalScriptsUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/LoadingUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/MovieUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/RollbackUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/SaveLoadUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/SceneTransitionUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/SettingsUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/TipsUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/TitleUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/VariableInputUI.prefab");
            AddAsset(UIConfiguration.DefaultPathPrefix, "Prefabs/DefaultUI/PauseUI.prefab");

            void AddActorAsset(ActorManagerConfiguration managerConfig, string relativeAssetPath)
            {
                var actorId    = System.IO.Path.GetFileNameWithoutExtension(relativeAssetPath);
                var actorMeta  = managerConfig.GetMetadataOrDefault(actorId);
                var category   = $"{actorMeta.Loader.PathPrefix}/{actorMeta.Guid}";
                var pathPrefix = actorMeta.Loader.PathPrefix;
                var assetPath  = $"{PathUtils.AbsoluteToAssetPath(PackagePath.PackageRootPath)}/{relativeAssetPath}";
                var assetGuid  = AssetDatabase.AssetPathToGUID(assetPath);

                AddRecord(category, pathPrefix, actorId, assetGuid);
            }

            void AddAsset(string categoryId, string relativeAssetPath)
            {
                var resourceName = System.IO.Path.GetFileNameWithoutExtension(relativeAssetPath);
                var assetPath    = $"{PathUtils.AbsoluteToAssetPath(PackagePath.PackageRootPath)}/{relativeAssetPath}";
                var assetGuid    = AssetDatabase.AssetPathToGUID(assetPath);

                AddRecord(categoryId, categoryId, resourceName, assetGuid);
            }
        }