예제 #1
0
 private static void ResetValues()
 {
     _mainJournal  = null;
     _finalPath    = "";
     _targetFolder = null;
     _tempPath     = "";
 }
예제 #2
0
        static void RemoveLODs(MenuCommand menuCommand)
        {
            var          activeObject = Selection.activeObject;
            DefaultAsset folderAsset  = null;

            if (IsDirectoryAsset(activeObject))
            {
                folderAsset = (DefaultAsset)activeObject;
                SelectAllGameObjectsUnderneathFolder(folderAsset, HasLODChain);
            }

            var go = menuCommand.context as GameObject;

            if (go)
            {
                RemoveLODs(go);
            }
            else
            {
                IterateOverSelectedGameObjects(RemoveLODs);
            }

            if (folderAsset)
            {
                Selection.activeObject = folderAsset;
            }
        }
예제 #3
0
        private static IEnumerable <Guid> GetGUIDs(IEnumerable <Object> targets)
        {
            HashSet <Guid> guids = new HashSet <Guid>();

            foreach (Object target in targets)
            {
                if (!target)
                {
                    continue;
                }

                DefaultAsset folder = target as DefaultAsset;

                if (folder)
                {
                    string folderPath = AssetDatabase.GetAssetPath(folder);

                    if (Directory.Exists(folderPath))
                    {
                        string[] searchGuids = AssetDatabase.FindAssets("t:object", new[] { folderPath });
                        searchGuids.ForEach(f => guids.Add(new Guid(f)));
                        continue;
                    }
                }

                if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(target, out string guid, out long _))
                {
                    guids.Add(new Guid(guid));
                }
            }

            return(guids);
        }
예제 #4
0
        public void OpenAssetFileInAseprite(DefaultAsset asset)
        {
            var assetPath = AssetDatabase.GetAssetPath(asset);
            var name      = Path.GetFileNameWithoutExtension(assetPath);

            AsepriteImporter.OpenFileInAseprite(_asepritePath, GetBasePath(assetPath), name);
        }
예제 #5
0
        public override bool OnLoadLuaCodeEditor(string assetsPath)
        {
            _luaCodes.Clear();
            DefaultAsset defaultAsset = AssetDatabase.LoadAssetAtPath <DefaultAsset>(assetsPath);

            if (defaultAsset)
            {
                Selection.activeObject = defaultAsset;
                TextAsset[] textAssets = Selection.GetFiltered <TextAsset>(SelectionMode.DeepAssets);
                Selection.activeObject = null;
                for (int i = 0; i < textAssets.Length; i++)
                {
                    if (textAssets[i].name.EndsWith(".lua"))
                    {
                        if (_luaCodes.ContainsKey(textAssets[i].name))
                        {
                            string path1 = AssetDatabase.GetAssetPath(_luaCodes[textAssets[i].name]);
                            string path2 = AssetDatabase.GetAssetPath(textAssets[i]);
                            Log.Error("加载Lua脚本失败:发现同名脚本 " + path1 + " 和 " + path2);
                        }
                        else
                        {
                            _luaCodes.Add(textAssets[i].name, textAssets[i]);
                        }
                    }
                }
                return(true);
            }
            else
            {
                Log.Error("热更新初始化失败:当前未创建热更新环境!");
                return(false);
            }
        }
예제 #6
0
 public void FindIncludedFiles(bool addMissing = false)
 {
     includes.Clear();
     foreach (string includePath in includePaths)
     {
         string localIncludePath = InkEditorUtils.CombinePaths(Path.GetDirectoryName(filePath), includePath);
         // This enables parsing ..\ and the like. Can we use Path.GetFullPath instead?
         var fullIncludePath = new FileInfo(localIncludePath).FullName;
         localIncludePath = InkEditorUtils.AbsoluteToUnityRelativePath(fullIncludePath);
         DefaultAsset includedInkFileAsset = AssetDatabase.LoadAssetAtPath <DefaultAsset>(localIncludePath);
         if (includedInkFileAsset == null)
         {
             Debug.LogError(filePath + " expected child .ink asset at '" + localIncludePath + "' but file was not found.", inkAsset);
         }
         else
         {
             InkFile includedInkFile = InkLibrary.GetInkFileWithFile(includedInkFileAsset, addMissing);
             if (includedInkFile == null)
             {
                 Debug.LogError(filePath + " expected child InkFile from .ink asset at '" + localIncludePath + "' but file was not found.", inkAsset);
             }
             else if (includedInkFile.includes.Contains(inkAsset))
             {
                 Debug.LogError("Circular INCLUDE reference between '" + filePath + "' and '" + includedInkFile.filePath + "'.", inkAsset);
             }
             else
             {
                 includes.Add(includedInkFileAsset);
             }
         }
     }
 }
예제 #7
0
        private void OnGUI()
        {
            if (!m_Prefs)
            {
                DefaultAsset newRef = EditorGUILayout.ObjectField("Ink File", null, typeof(DefaultAsset), false) as DefaultAsset;

                if (newRef == null)
                {
                    return;
                }

                m_Prefs = InkTodoPrefs.Load(newRef);
                EditorPrefs.SetString(kInkTodoFilePref, AssetDatabase.GetAssetPath(newRef));
            }

            m_Prefs = EditorGUILayout.ObjectField("Ink Todo Prefs File", m_Prefs, typeof(InkTodoPrefs), false) as InkTodoPrefs;

            if (m_Prefs == null)
            {
                return;
            }

            SerializedObject so = new SerializedObject(m_Prefs);

            EditorGUILayout.PropertyField(so.FindProperty("m_InkFileAssets"), true);

            m_Prefs.OnGUI();
            if (GUI.changed)
            {
                EditorUtility.SetDirty(m_Prefs);
            }

            so.ApplyModifiedProperties();
        }
예제 #8
0
 /// <summary>
 /// Gets the ink file from the .ink file reference.
 /// </summary>
 /// <returns>The ink file with path.</returns>
 /// <param name="path">Path.</param>
 public static InkFile GetInkFileWithFile(DefaultAsset file)
 {
     if (InkLibrary.Instance.inkLibrary == null)
     {
         return(null);
     }
     if (Instance.inkLibraryDictionary == null)
     {
         Debug.LogWarning("GetInkFileWithFile: inkLibraryDictionary was null! This should never occur, but is handled following a user reported bug. If this has never been seen long after 12/08/2020, it can be safely removed");
         CreateDictionary();
     }
     foreach (InkFile inkFile in Instance.inkLibrary)
     {
         if (inkFile.inkAsset == file)
         {
             return(inkFile);
         }
     }
     System.Text.StringBuilder listOfFiles = new System.Text.StringBuilder();
     foreach (InkFile inkFile in Instance.inkLibrary)
     {
         listOfFiles.AppendLine(inkFile.ToString());
     }
     Debug.LogWarning(file + " missing from ink library. Please rebuild.\n" + listOfFiles);
     return(null);
 }
예제 #9
0
        private void ShowAnimatorControllerGUI()
        {
            ShowHeadline("Animator Controller + Animations");

            DefaultAsset droppedAsset = ShowDropButton <DefaultAsset>(importer.canImportAnimations);

            if (droppedAsset != null)
            {
                EditorUtility.DisplayProgressBar("Import Animator Controller", "Importing...", 0);
                try
                {
                    var animationInfo = importer.CreateAnimationsForAssetFile(droppedAsset);

                    if (animationInfo != null)
                    {
                        importer.CreateAnimatorController(animationInfo);
                    }

                    AssetDatabase.Refresh();
                }
                catch (Exception error)
                {
                    Debug.LogWarning(error.ToString());
                    throw;
                }

                EditorUtility.ClearProgressBar();
            }
        }
예제 #10
0
    public void DropAreaGUI()
    {
        DefaultAsset obj = (DefaultAsset)m_csoundAsset.objectReferenceValue;

        //
        EditorGUI.BeginChangeCheck();
        obj = (DefaultAsset)EditorGUILayout.ObjectField("Csd Asset", obj, typeof(DefaultAsset), false);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(target, "Set Csd");
            // Debug.Log("selected new asset!");
            if (obj == null ||
                !AssetDatabase.GetAssetPath(obj).EndsWith(".csd", true, System.Globalization.CultureInfo.CurrentCulture))
            {
                // Debug.Log("asset is not valid, set Csd NULL");
                SetCsd(null);
            }
            else
            {
                //Debug.Log("change asset, it is valid! setting csd");
                if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(obj, out string guid, out long localId))
                {
                    // Debug.Log("guid valid: " + guid + " loc " + localId);
                    SetCsd(guid);
                }
                else
                {
                    Debug.LogWarning("GUID NOT FOUND");
                    SetCsd(null);
                }
            }
예제 #11
0
        /// <summary>
        /// Updates the ink library. Executed whenever an ink file is changed by InkToJSONPostProcessor
        /// Can be called manually, but incurs a performance cost.
        /// </summary>
        public static void Rebuild()
        {
            // Remove any old file connections
            Clean();

            // Add any new file connections (if any are found it replaces the old library entirely)
            string[]       inkFilePaths      = GetAllInkFilePaths();
            bool           inkLibraryChanged = false;
            List <InkFile> newInkLibrary     = new List <InkFile>(inkFilePaths.Length);

            for (int i = 0; i < inkFilePaths.Length; i++)
            {
                InkFile inkFile = GetInkFileWithAbsolutePath(inkFilePaths [i]);
                // If the ink library doesn't have a representation for this file, then make one
                if (inkFile == null)
                {
                    inkLibraryChanged = true;
                    string       localAssetPath = InkEditorUtils.AbsoluteToUnityRelativePath(inkFilePaths [i]);
                    DefaultAsset inkFileAsset   = AssetDatabase.LoadAssetAtPath <DefaultAsset>(localAssetPath);
                    // If the ink file can't be found, it might not yet have been imported. We try to manually import it to fix this.
                    if (inkFileAsset == null)
                    {
                        AssetDatabase.ImportAsset(localAssetPath);
                        inkFileAsset = AssetDatabase.LoadAssetAtPath <DefaultAsset>(localAssetPath);
                        if (inkFileAsset == null)
                        {
                            Debug.LogWarning("Ink File Asset not found at " + localAssetPath + ". This can occur if the .meta file has not yet been created. This issue should resolve itself, but if unexpected errors occur, rebuild Ink Library using Assets > Recompile Ink");
                            continue;
                        }
                    }
                    inkFile = new InkFile(inkFileAsset);
                }
                newInkLibrary.Add(inkFile);
            }
            if (inkLibraryChanged)
            {
                Instance.inkLibrary = newInkLibrary;
                SortInkLibrary();
            }
            CreateDictionary();

            // Validate the meta files
            var  metaFiles        = Instance.inkLibrary.Select(x => x.metaInfo);
            bool metaFilesChanged = !InkMetaLibrary.Instance.metaLibrary.SequenceEqual(metaFiles);

            if (metaFilesChanged)
            {
                InkMetaLibrary.Instance.metaLibrary = metaFiles.ToList();
            }

            InkMetaLibrary.RebuildInkFileConnections();

            foreach (InkFile inkFile in Instance.inkLibrary)
            {
                inkFile.FindCompiledJSONAsset();
            }
            SaveToFile();

            Debug.Log("Ink Library was rebuilt.");
        }
예제 #12
0
        private static MetaSpriteImportData GetMetaData(DefaultAsset asset)
        {
            var path   = AssetDatabase.GetAssetPath(asset);
            var import = AssetImporter.GetAtPath(path);

            return(JsonUtility.FromJson <MetaSpriteImportData>(import.userData));
        }
예제 #13
0
        void OnGUI()
        {
            _width        = EditorGUILayout.IntField("Width", _width);
            _height       = EditorGUILayout.IntField("Height", _height);
            _unitLength   = EditorGUILayout.FloatField("Unit Length", _unitLength);
            _isHorizontal = EditorGUILayout.Toggle("Horizontal", _isHorizontal);

            GUILayout.Space(10);

            _exportDirectory =
                (DefaultAsset)EditorGUILayout.ObjectField("Directory", _exportDirectory, typeof(DefaultAsset), true);
            _exportMeshName = EditorGUILayout.TextField("Export Mesh Name", _exportMeshName);

            if (_exportDirectory != null && !string.IsNullOrEmpty(_exportMeshName))
            {
                if (GUILayout.Button("Export"))
                {
                    var newMesh = PlaneMeshGenerator.GenerateHorizontal(_width, _height, _unitLength, _isHorizontal);
                    Export(newMesh);
                }
            }

            if (GUILayout.Button("Refresh Preview"))
            {
                var newMesh = PlaneMeshGenerator.GenerateHorizontal(_width, _height, _unitLength, _isHorizontal);
                _gameObjectEditor = Editor.CreateEditor(newMesh);
            }

            if (_gameObjectEditor != null)
            {
                _gameObjectEditor.OnInteractivePreviewGUI(GUILayoutUtility.GetRect(200, 200), new GUIStyle());
            }
        }
예제 #14
0
        public static bool OnOpenAsset(int id, int line)
        {
            ResetValues();

            Journal journal = EditorUtility.InstanceIDToObject(id) as Journal;

            if (journal != null)
            {
                _mainJournal = journal;

                if (_finalPath == "")
                {
                    _finalPath = AssetDatabase.GetAssetPath(_mainJournal.GetFolderPath());
                    if (_finalPath != null && !_finalPath.Equals(""))
                    {
                        _targetFolder = _mainJournal.GetFolderPath();
                    }
                }

                DisplayEditorWindow();
                _forceRefresh = true;
                return(true);
            }

            return(false);
        }
예제 #15
0
    private void OnGUI()
    {
        try
        {
            EditorGUILayout.LabelField("ページ");
            R_page = EditorGUILayout.ObjectField("右ページ", R_page, typeof(GameObject), true) as GameObject;
            L_page = EditorGUILayout.ObjectField("左ページ", L_page, typeof(GameObject), true) as GameObject;
            EditorGUILayout.LabelField("ページ送りボタン");
            R_Bar = EditorGUILayout.ObjectField("戻るボタン", R_Bar, typeof(GameObject), true) as GameObject;
            L_Bar = EditorGUILayout.ObjectField("進むボタン", L_Bar, typeof(GameObject), true) as GameObject;
            EditorGUILayout.LabelField(" ");

            VRCWoald = EditorGUILayout.ObjectField("ワールドオブジェクト", VRCWoald, typeof(GameObject), true) as GameObject;

            page_fold = (DefaultAsset)EditorGUILayout.ObjectField("ページマテリアルフォルダ", page_fold, typeof(DefaultAsset), true);

            local = EditorGUILayout.Toggle("動作をローカルにする", local);
            gimic = EditorGUILayout.Toggle("ページにギミックを仕込む", gimic);

            if (GUILayout.Button("製本"))
            {
                Make();
            }
        }
        catch (System.FormatException) { }
    }
예제 #16
0
        private void ShowAnimatorOverrideControllerGUI()
        {
            ShowHeadline("Animator Override Controller + Animations");

            importer.baseController = EditorGUILayout.ObjectField("Based on Controller:", importer.baseController, typeof(RuntimeAnimatorController), false) as RuntimeAnimatorController;

            DefaultAsset droppedAsset = ShowDropButton <DefaultAsset>(importer.canImportAnimationsForOverrideController);

            if (droppedAsset != null)
            {
                EditorUtility.DisplayProgressBar("Import Animator Override Controller", "Importing...", 0);
                try
                {
                    var animationInfo = importer.CreateAnimationsForAssetFile(droppedAsset);

                    if (animationInfo != null)
                    {
                        importer.CreateAnimatorOverrideController(animationInfo);
                    }

                    AssetDatabase.Refresh();
                }
                catch (Exception error)
                {
                    Debug.LogWarning(error.ToString());
                    throw;
                }

                EditorUtility.ClearProgressBar();
            }
        }
예제 #17
0
    private void OnGUI()
    {
        GUILayout.Label("Through this window you'll be able to set the folder where the asset will save it's Materials",
                        EditorStyles.boldLabel);

        GUILayout.Space(20);

        materialTargetFolder = (DefaultAsset)EditorGUILayout.ObjectField(
            "New Material Folder",
            materialTargetFolder,
            typeof(DefaultAsset),
            false);

        if (materialTargetFolder != null && IsAssetAFolder(materialTargetFolder))
        {
            string path = AssetDatabase.GetAssetPath(materialTargetFolder);
            PlayerPrefs.SetString("All1ShaderMaterials", path);
            EditorGUILayout.HelpBox(
                "Valid folder! Material save path: " + path,
                MessageType.Info,
                true);
        }
        else
        {
            EditorGUILayout.HelpBox(
                "Select the new Material Folder",
                MessageType.Warning,
                true);
        }
    }
예제 #18
0
        static string GetImportSettingsPath(DefaultAsset asset)
        {
            var guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(asset));
            var path = "Assets/Config/MetaSprite/FileSettings/" + guid + ".asset";

            return(path);
        }
예제 #19
0
        public static string GetImportSettingsPath(DefaultAsset asset)
        {
            var guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(asset));
            var path = pluginPath + "/FileSettings/" + guid + ".asset";

            return(path);
        }
예제 #20
0
        private void ShowAnimatorOverrideControllerGUI()
        {
            ShowHeadline("Animator Override Controller + Animations");

            RuntimeAnimatorController newBaseController = EditorGUILayout.ObjectField("Based on Controller:", _baseController, typeof(RuntimeAnimatorController), false) as RuntimeAnimatorController;

            if (newBaseController != _baseController)
            {
                _baseController = newBaseController;
                SaveUserConfig();
            }

            DefaultAsset droppedAsset = ShowDropButton <DefaultAsset>(canImportAnimations && _baseController != null);

            if (droppedAsset != null)
            {
                if (_baseController == null)
                {
                    Debug.LogWarning("Please assign an Animator Controller first");
                    return;
                }

                var animationInfo = CreateAnimationsForAssetFile(droppedAsset);

                if (animationInfo != null)
                {
                    CreateAnimatorOverrideController(animationInfo);
                }

                AssetDatabase.Refresh();
            }
        }
예제 #21
0
        private static void OnSettingsGUI(SerializedObject serializedObject)
        {
            SerializedProperty defaultGeneratedScriptsFolder      = serializedObject.FindProperty("defaultGeneratedScriptsPath");
            SerializedProperty defaultNamespaceSerializedProperty = serializedObject.FindProperty("defaultNamespace");
            DefaultAsset       defaultAsset = AssetDatabase.LoadAssetAtPath <DefaultAsset>(defaultGeneratedScriptsFolder
                                                                                           .stringValue);

            using (EditorGUI.ChangeCheckScope changeCheck = new EditorGUI.ChangeCheckScope())
            {
                DefaultAsset newFolder = EditorGUILayout.ObjectField("Default Generated Scripts Folder", defaultAsset, typeof(DefaultAsset), false) as DefaultAsset;
                if (changeCheck.changed)
                {
                    defaultGeneratedScriptsFolder.stringValue = AssetDatabase.GetAssetPath(newFolder);
                    defaultGeneratedScriptsFolder.serializedObject.ApplyModifiedProperties();
                }
            }

            using (EditorGUI.ChangeCheckScope changeCheck = new EditorGUI.ChangeCheckScope())
            {
                string newNamespace = EditorGUILayout.DelayedTextField("Default Namespace", defaultNamespaceSerializedProperty.stringValue);
                if (changeCheck.changed)
                {
                    defaultNamespaceSerializedProperty.stringValue = newNamespace;
                    defaultNamespaceSerializedProperty.serializedObject.ApplyModifiedProperties();
                }
            }
        }
예제 #22
0
 private void OnValidate()
 {
     if (!AssetDatabase.IsValidFolder(FolderPath))
     {
         _outputFolder = null;
     }
 }
예제 #23
0
        public void Create()
        {
            foreach (NativePlugin plugin in NativePluginSettings.plugins)
            {
                if (plugin != this && plugin.Name == Name)
                {
                    throw new Exception("Plugin name \"" + Name + "\" already exists.");
                }
            }
            if (Directory.Exists("Assets/" + Name))
            {
                throw new Exception("Assets/" + Name + " already exists.");
            }

            FileUtil.CopyFileOrDirectory("Assets/NativePluginBuilder/Boilerplate~", "Assets/" + Name);

            FileUtil.MoveFileOrDirectory("Assets/" + Name + "/Plugin.asmdef", "Assets/" + Name + "/" + Name + ".asmdef");
            FileUtil.MoveFileOrDirectory("Assets/" + Name + "/PluginExample.cs", "Assets/" + Name + "/" + Name + "Example.cs");
            FileUtil.MoveFileOrDirectory("Assets/" + Name + "/Plugin.cs", "Assets/" + Name + "/" + Name + ".cs");

            ProcessTemplateFile("Assets/" + Name + "/" + Name + ".asmdef");
            ProcessTemplateFile("Assets/" + Name + "/" + Name + ".cs");
            ProcessTemplateFile("Assets/" + Name + "/" + Name + "Example.cs");
            ProcessTemplateFile("Assets/" + Name + "/Plugins/WebGL/PluginJS.jslib");

            //Refresh to detect changes
            AssetDatabase.Refresh();

            sourceFolder       = Path.GetFullPath("Assets/" + Name + "/NativeSource~/Source");
            buildFolder        = Path.GetFullPath("Assets/" + Name + "/NativeSource~/Build");
            pluginBinaryFolder = AssetDatabase.LoadAssetAtPath <DefaultAsset>("Assets/" + Name + "/Plugins");
            AssetDatabase.CreateAsset(this, "Assets/" + Name + "/" + Name + ".asset");

            AssetDatabase.SaveAssets();
        }
예제 #24
0
        public InkFile(DefaultAsset inkAsset)
        {
            Debug.Assert(inkAsset != null);
            this.inkAsset = inkAsset;

            ParseContent();
        }
예제 #25
0
        static IEnumerator GenerateLODsCoroutine(MenuCommand menuCommand)
        {
            var          activeObject = Selection.activeObject;
            DefaultAsset folderAsset  = null;

            if (IsDirectoryAsset(activeObject))
            {
                folderAsset = (DefaultAsset)activeObject;
                SelectAllGameObjectsUnderneathFolder(folderAsset, prefab => !HasLODChain(prefab));
            }

            yield return(null);

            var go = menuCommand.context as GameObject;

            if (go)
            {
                GenerateLODs(go);
            }
            else
            {
                IterateOverSelectedGameObjects(current =>
                {
                    RemoveChildrenLODGroups(current);
                    GenerateLODs(current);
                });
            }

            if (folderAsset)
            {
                Selection.activeObject = folderAsset;
            }
        }
예제 #26
0
        protected async Task Sign(string path, TaskToken task, string entitlementsPath = null)
        {
            // Delete .meta files Unity might have erroneously copied to the build
            // and which will cause the signing to fail.
            // See: https://issuetracker.unity3d.com/issues/macos-standalone-build-contains-meta-files-inside-native-plugin-bundles
            if (Directory.Exists(path))
            {
                var metas = Directory.GetFiles(path, "*.meta", SearchOption.AllDirectories);
                foreach (var meta in metas)
                {
                    File.Delete(meta);
                }
            }

            var entitlements = "";

            if (entitlementsPath != null)
            {
                entitlements = $" --entitlements '{entitlementsPath}'";
            }

            var args = $"--force"
                       + $" --deep"
                       + $" --timestamp"
                       + $" --options=runtime"
                       + entitlements
                       + $" --sign '{appSignIdentity}'"
                       + $" '{path}'";

            await Execute(new ExecutionArgs("codesign", args), task);
        }
예제 #27
0
 public void OnValidObjectsDropped(UnityEngine.Object[] droppedObjs)
 {
     for (int objIdx = 0; objIdx < droppedObjs.Length; objIdx++)
     {
         Texture2D tex = droppedObjs[objIdx] as Texture2D;
         if (tex != null)
         {
             m_allTextures.Add(tex);
         }
         else
         {
             DefaultAsset asset = droppedObjs[objIdx] as DefaultAsset;
             if (asset != null)
             {
                 string path = AssetDatabase.GetAssetPath(asset);
                 if (AssetDatabase.IsValidFolder(path))
                 {
                     string[] pathArr  = { path };
                     string[] texInDir = AssetDatabase.FindAssets(TextureFilter, pathArr);
                     for (int texIdx = 0; texIdx < texInDir.Length; texIdx++)
                     {
                         Texture2D internalTex = AssetDatabase.LoadAssetAtPath <Texture2D>(AssetDatabase.GUIDToAssetPath(texInDir[texIdx]));
                         if (internalTex != null)
                         {
                             m_allTextures.Add(internalTex);
                         }
                     }
                 }
             }
         }
     }
 }
 public void FindIncludedFiles()
 {
     includes.Clear();
     foreach (string includePath in includePaths)
     {
         string       localIncludePath     = InkEditorUtils.CombinePaths(Path.GetDirectoryName(inkFile.filePath), includePath);
         DefaultAsset includedInkFileAsset = AssetDatabase.LoadAssetAtPath <DefaultAsset>(localIncludePath);
         if (includedInkFileAsset == null)
         {
             Debug.LogError(inkFile.filePath + " expected child .ink asset at " + localIncludePath + " but file was not found.");
         }
         InkFile includedInkFile = InkLibrary.GetInkFileWithFile(includedInkFileAsset);
         if (includedInkFile == null)
         {
             Debug.LogError(inkFile.filePath + " expected child InkFile from .ink asset at " + localIncludePath + " but file was not found.");
         }
         else if (includedInkFile.metaInfo.includes.Contains(inkAsset))
         {
             Debug.LogError("Circular INCLUDE reference between " + inkFile.filePath + " and " + includedInkFile.metaInfo.inkFile.filePath + ".");
         }
         else
         {
             includes.Add(includedInkFileAsset);
         }
     }
 }
예제 #29
0
 public static void ShowWindow()
 {
     once          = false;
     folder        = null;
     currentFolder = null;
     GetWindow <PackageExporterWindow>(false, "Package Exporter", true);
 }
예제 #30
0
        private static List <InkFileInfo> GetInkFiles(string storyScriptPath)
        {
            string       rootPath    = Path.GetDirectoryName(storyScriptPath)?.Replace('\\', '/').TrimEnd('/');
            DefaultAsset rootInkFile = AssetDatabase.LoadAssetAtPath <DefaultAsset>(storyScriptPath);
            InkFileInfo  rootInfo    = new InkFileInfo(rootInkFile, rootPath);

            Queue <InkFileInfo> queue = new Queue <InkFileInfo>(new[] { rootInfo });
            Dictionary <string, InkFileInfo> inkFiles = new Dictionary <string, InkFileInfo>(StringComparer.OrdinalIgnoreCase);

            while (queue.Count > 0)
            {
                InkFileInfo info = queue.Dequeue();
                inkFiles[info.Path] = info;

                foreach (string includePath in info.Includes)
                {
                    if (!inkFiles.ContainsKey(includePath))
                    {
                        queue.Enqueue(new InkFileInfo(includePath, rootPath));
                    }
                }
            }

            return(inkFiles.Values.ToList());
        }