예제 #1
0
    public static PrefabInstance CreateFromAssetPath(AssetPath inPath)
    {
        GameObject resource = inPath.Load<GameObject>();

        GameObject gameObject = GameObject.Instantiate<GameObject>(resource);
        PrefabInstance prefabInstance = gameObject.GetComponentInChildren<PrefabInstance>(true);
        if(prefabInstance)
        {
            prefabInstance.PrefabSource = inPath;
        }

        return prefabInstance;
    }
        public override CompilerMessage[] GetCompilerMessages()
        {
            if (!Poll())
            {
                Debug.LogWarning("Compile process is not finished yet. This should not happen.");
            }

            if (process == null)
            {
                return(new CompilerMessage[0]);
            }

            var outputFile = AssetPath.Combine(tempOutputDirectory, assembly.Filename);

            DumpStreamOutputToLog(outputFile);

            return(CreateOutputParser().Parse(
                       GetStreamContainingCompilerMessages(),
                       CompilationHadFailure(),
                       assembly.Filename
                       ).ToArray());
        }
예제 #3
0
        private string GetBundleNameOfExternalScene(ParsedNode node)
        {
            var bundleName = string.Empty;
            var scenePath  = AssetPath.CorrectSlashes(node.ContentsPath);

            foreach (var sceneExtension in scenesExtensions)
            {
                string sceneBundle;
                if (!sceneToBundleMap.TryGetValue(scenePath + sceneExtension, out sceneBundle))
                {
                    continue;
                }

                bundleName = sceneBundle;
                break;
            }
            if (string.IsNullOrEmpty(bundleName))
            {
                Console.WriteLine("Warning! Can not find external scene \'{0}\' in \'{1}!\'", scenePath, currentCookingScene);
            }
            return(bundleName);
        }
        internal static void WriteContextFiles(string nameSpace)
        {
            if (string.IsNullOrEmpty(nameSpace))
            {
                nameSpace = "MyNamespace";
            }

            var filePath = AssetPath.Combine(Application.dataPath, "BasicContext.cs");

            using (var writer = new StreamWriter(filePath))
            {
                writer.Write(Template.ContextTemplate, nameSpace);
            }

            filePath = AssetPath.Combine(Application.dataPath, "BasicContextProvider.cs");
            using (var writer = new StreamWriter(filePath))
            {
                writer.Write(Template.ProviderTemplate, nameSpace);
            }

            AssetDatabase.Refresh();
        }
예제 #5
0
        internal bool Delete()
        {
            if (_aiStorage == null)
            {
                return(true);
            }

            var path = AssetPath.Combine(AIGeneralSettings.instance.storagePath, string.Concat(_aiStorage.name, ".asset"));

            if (!AssetDatabase.DeleteAsset(path))
            {
                Debug.LogWarning(this.ToString() + " could not be deleted, path checked: " + path);
                return(false);
            }

            if (UserSettings.instance.autoGenerateNameMap)
            {
                AINameMapGenerator.WriteNameMapFile();
            }

            return(true);
        }
        public List <string> Get(string folderToLookForResponseFilesIn)
        {
            if (!string.IsNullOrEmpty(folderToLookForResponseFilesIn) && !Path.IsPathRooted(folderToLookForResponseFilesIn))
            {
                folderToLookForResponseFilesIn = AssetPath.Combine(ProjectPath, folderToLookForResponseFilesIn);
            }

            var result = new List <string>();

            var folderResponseFile = GetCompilerSpecific(folderToLookForResponseFilesIn);

            if (!string.IsNullOrEmpty(folderResponseFile))
            {
                AddIfNotNull(result, folderResponseFile);
            }
            else
            {
                AddIfNotNull(result, GetDefaultResponseFiles());
            }

            return(result);
        }
        public ContentPlan BuildPlan()
        {
            var library      = new TransformerPolicyLibrary(_policies);
            var combinations = new AssetCombinationCache();

            if (_combination != null)
            {
                combinations.StoreCombination(_combination.MimeType, _combination);
            }

            var pipeline = new AssetFileGraph();

            _files.Each(f =>
            {
                var path = new AssetPath(AssetFileGraph.Application, f.Name, f.Folder);
                pipeline.AddFile(path, f);
            });

            var planner = new ContentPlanner(combinations, pipeline, library);

            return(planner.BuildPlanFor(_name));
        }
예제 #8
0
        public Document OpenDocument(string path, bool pathIsGlobal = false)
        {
            string localPath = path;

            if (pathIsGlobal)
            {
                if (this == Null || !Current.TryGetAssetPath(path, out localPath))
                {
                    OpenFileOutsideProjectAttempt(path);
                    return(null);
                }
            }
            localPath = AssetPath.CorrectSlashes(localPath);
            var doc = Documents.FirstOrDefault(i => i.Path == localPath);

            if (doc == null)
            {
                var    tmpFile = AutosaveProcessor.GetTemporalFilePath(localPath);
                string systemPath;
                if (GetSystemPath(tmpFile, out systemPath) && TempFileLoadConfirmation.Invoke(localPath))
                {
                    doc = new Document(tmpFile);
                    doc.SaveAs(localPath);
                }
                else
                {
                    doc = new Document(localPath);
                }
                if (systemPath != null)
                {
                    File.Delete(systemPath);
                }
                documents.Add(doc);
            }
            doc.MakeCurrent();
            AddRecentDocument(doc.Path);
            return(doc);
        }
        /// <summary>
        /// Imports the corresponding asset.
        /// </summary>
        public override void Import()
        {
            // Create expression data.
            var expressionData = CubismExpressionData.CreateInstance(ExpressionJson);

            AssetDatabase.CreateAsset(expressionData, AssetPath.Replace(".exp3.json", ".exp3.asset"));

            // Add expression data to expression list.
            var directoryName      = Path.GetDirectoryName(AssetPath).ToString();
            var modelDir           = Path.GetDirectoryName(directoryName).ToString();
            var modelName          = Path.GetFileName(modelDir).ToString();
            var expressionListPath = Path.GetDirectoryName(directoryName).ToString() + "/" + modelName + ".expressionList.asset";
            var expressionList     = AssetDatabase.LoadAssetAtPath <CubismExpressionList>(expressionListPath);

            // Create expression list.
            if (expressionList == null)
            {
                expressionList = ScriptableObject.CreateInstance <CubismExpressionList>();
                expressionList.CubismExpressionObjects = new CubismExpressionData[0];
                AssetDatabase.CreateAsset(expressionList, expressionListPath);
            }

            var instanceId  = expressionData.GetInstanceID();
            var motionIndex = Array.IndexOf(expressionList.CubismExpressionObjects, instanceId);

            if (motionIndex != -1)
            {
                expressionList.CubismExpressionObjects[motionIndex] = expressionData;
            }
            else
            {
                motionIndex = expressionList.CubismExpressionObjects.Length;
                Array.Resize(ref expressionList.CubismExpressionObjects, motionIndex + 1);
                expressionList.CubismExpressionObjects[motionIndex] = expressionData;
            }

            EditorUtility.SetDirty(expressionList);
        }
예제 #10
0
        public static bool ExtractAssetPathOrShowAlert(string filePath, out string assetPath, out string assetType)
        {
            string path       = AssetPath.CorrectSlashes(filePath);
            string assetsPath = AssetPath.CorrectSlashes(Core.Project.Current.AssetsDirectory);

            if (Path.IsPathRooted(path))
            {
                if (!path.StartsWith(assetsPath, StringComparison.CurrentCultureIgnoreCase))
                {
                    AlertDialog.Show($"Asset '{filePath}' outside the project directory");
                    assetPath = null;
                    assetType = null;
                    return(false);
                }
                else
                {
                    path = path.Substring(assetsPath.Length + 1);
                }
            }
            assetPath = Path.ChangeExtension(path, null);
            assetType = Path.GetExtension(path).ToLower();
            return(true);
        }
예제 #11
0
    void refresh(SpriteDatabase db)
    {
        Debug.Log("Refreshing sprite database \"" + db.name + "\"");
        db.sprites = new List <Sprite>();
        string path = AssetDatabase.GetAssetPath(db);

        path = AssetPath.getAbsolutePath(path);
        path = path.Replace(Path.GetFileName(path), "");
        foreach (var f in FileSearch.search(path, "*"))
        {
            var assets = AssetDatabase.LoadAllAssetsAtPath(AssetPath.getRelativePath(f.FullName));
            foreach (var a in assets)
            {
                Sprite s = a as Sprite;
                if (s != null)
                {
                    db.sprites.Add(s);
                    Debug.Log("Find sprite \"" + s.name + "\"");
                }
            }
        }
        Debug.Log("Sprite database \"" + db.name + "\" refreshed:(" + db.sprites.Count + ")");
    }
예제 #12
0
        public static void AddToBundleConfig(string assetFullPath)
        {
            if (Path.GetFileName(assetFullPath) == Constant.ASSET_CONFIG_NAME)
            {
                ChangeAssetConfigBundleName(assetFullPath);
            }
            else
            {
                ChangeAssetBundleName(assetFullPath);

                var assetPath   = AssetPath.GetAssetPathFromBundlePath(assetFullPath);
                var assetConfig = GetAssetConfig();
                assetConfig.Add(new AssetInfo()
                {
                    assetPath    = assetPath,
                    assetName    = AssetPath.GetAssetName(assetPath),
                    bundleName   = AssetPath.GetBundleName(assetPath, assetFullPath, assetConfig.indvAssetPathList),
                    isFromBundle = true
                });

                EditorUtility.SetDirty(assetConfig);
            }
        }
예제 #13
0
        static void ChangeAssetBundleName(string assetFullPath)
        {
            if (assetFullPath.Contains(Constant.EXTENSION_META))
            {
                return;
            }

            var assetSetting    = AssetDatabase.LoadAssetAtPath <AssetSetting>(AssetEditorConstant.ASSET_SETTING_PATH);
            var assetPath       = AssetPath.GetAssetPathFromBundlePath(assetFullPath);
            var assetBundleName = AssetPath.GetBundleName(assetPath, assetFullPath, assetSetting.assetConfig.indvAssetPathList);
            var assetName       = AssetPath.GetAssetName(assetPath);

            var assetImporter = AssetImporter.GetAtPath(assetFullPath);

            if (assetImporter.name != assetName ||
                assetImporter.assetBundleName != assetBundleName)
            {
                assetImporter.assetBundleName = assetBundleName;
                assetImporter.name            = assetName;

                EditorUtility.SetDirty(assetImporter);
            }
        }
예제 #14
0
        private static string GetPromptImagePath(this GamepadAxis axis, GamepadType type)
        {
            if (type == GamepadType.Unknown)
            {
                type = GamepadType.Xbox360;
            }

            string buttonName;

            switch (axis)
            {
            case GamepadAxis.LeftStickX:
            case GamepadAxis.LeftStickY:
            {
                buttonName = "left_stick";
                break;
            }

            case GamepadAxis.RightStickX:
            case GamepadAxis.RightStickY:
            {
                buttonName = "right_stick";
                break;
            }

            default:
            {
                buttonName = axis.ToString().ToLowerUnderscored();
                break;
            }
            }

            return(AssetPath.Combine(
                       "gui/prompts/" + type.ToString().ToLowerUnderscored(),
                       buttonName + ".png"
                       ));
        }
예제 #15
0
        public static Texture GetLocalised(string path, Language language, bool filter)
        {
            // Try the current language and it's fallbacks
            bool triedEnglish = false;

            while (language != null)
            {
                var specificPath = AssetPath.Combine(
                    AssetPath.GetDirectoryName(path),
                    AssetPath.GetFileNameWithoutExtension(path) + "_" + language.Code + ".png"
                    );
                if (Assets.Assets.Exists <Texture>(specificPath))
                {
                    return(Texture.Get(specificPath, filter));
                }
                if (language.Code == "en")
                {
                    triedEnglish = true;
                }
                language = language.Fallback;
            }
            if (!triedEnglish)
            {
                // Try english
                var englishPath = AssetPath.Combine(
                    AssetPath.GetDirectoryName(path),
                    AssetPath.GetFileNameWithoutExtension(path) + "_en.png"
                    );
                if (Assets.Assets.Exists <Texture>(englishPath))
                {
                    return(Texture.Get(englishPath, filter));
                }
            }

            // Try unlocalised
            return(Texture.Get(path, filter));
        }
        protected override void beforeEach()
        {
            var assetPath = new AssetPath("scripts/combo1.js");

            assetPath.IsBinary().ShouldBeFalse();

            theFiles = new AssetFile[] {
                new AssetFile("script1.js")
                {
                    FullPath = "1.js"
                },
                new AssetFile("script2.js")
                {
                    FullPath = "2.js"
                },
                new AssetFile("script3.js")
                {
                    FullPath = "3.js"
                },
                new AssetFile("script4.js")
                {
                    FullPath = "4.js"
                },
            };

            MockFor <IContentPlanCache>().Stub(x => x.SourceFor(assetPath))
            .Return(MockFor <IContentSource>());

            MockFor <IContentSource>().Expect(x => x.GetContent(MockFor <IContentPipeline>()))
            .Return(theContent);

            MockFor <IContentSource>().Stub(x => x.Files).Return(theFiles);

            theAction = files => _files = files;

            wasReturned = ClassUnderTest.Write(assetPath, theAction);
        }
예제 #17
0
        private bool ChangeNameMapFolder(string proposedFolder)
        {
            if (string.Equals(proposedFolder, _nameMapPath, StringComparison.OrdinalIgnoreCase) || !AssetPath.IsProjectPath(proposedFolder))
            {
                return(false);
            }

            proposedFolder = AssetPath.ProjectRelativePath(proposedFolder);
            AssetPath.EnsurePath(proposedFolder);

            //Move map from current location to new location.
            if (!string.IsNullOrEmpty(_nameMapPath))
            {
                var existingFile = AssetPath.Combine(AssetPath.GetFullPath(_nameMapPath), NameMapFileName);

                if (File.Exists(existingFile))
                {
                    var oldFilePath = AssetPath.Combine(_nameMapPath, NameMapFileName);
                    var newFilePath = AssetPath.Combine(proposedFolder, NameMapFileName);

                    var msg = AssetDatabase.MoveAsset(oldFilePath, newFilePath);
                    if (!string.IsNullOrEmpty(msg))
                    {
                        EditorUtility.DisplayDialog("Error Moving Asset", msg, "Ok");
                        return(false);
                    }
                    else
                    {
                        AssetDatabase.Refresh();
                    }
                }
            }

            _nameMapPath = proposedFolder;

            return(true);
        }
예제 #18
0
        protected virtual void OnSelectClicked()
        {
            var current = CoalescedPropertyValue().GetDataflow();

            current.Poll();
            var value = current.Value;
            var path  = ValueToStringConverter(value.Value);
            var dlg   = new FileDialog {
                AllowedFileTypes = allowedFileTypes,
                Mode             = FileDialogMode.Open,
                InitialDirectory =
                    current.GotValue && value.IsDefined && !string.IsNullOrEmpty(path) && TryGetClosestAvailableDirectory(
                        AssetPath.Combine(Project.Current.AssetsDirectory, path), out var dir) ?
                    dir : Directory.Exists(LastOpenedDirectory) ?
                    LastOpenedDirectory : Project.Current.AssetsDirectory
            };

            if (dlg.RunModal())
            {
                SetFilePath(dlg.FileName);
                LastOpenedDirectory = Path.GetDirectoryName(dlg.FileName);
            }
        }
    }
예제 #19
0
        /// <summary>
        /// スキルの実行
        /// </summary>
        /// <param name="battleData"></param>
        public void InvokeSkill(MenkoBattleData battleData, Menko invoker)
        {
            Debug.Log("Invoke Skill");
            string    skillPath   = AssetPath.GetSkillPrefabPath(battleData.SkillData.UseSkillID);
            var       skillPrefab = AssetManager.Load <SkillBase>(skillPath).Asset as SkillBase;
            SkillBase skill       = GameObject.Instantiate(skillPrefab);

            skill.gameObject.SetActive(false);
            skill.transform.position = invoker.transform.position;
            skill.transform.SetPosY(0f);

            var playTask = new SkillPlayTask(manager, invoker, battleData, skill, NextCall);

            if (currentPlay == null)
            {
                manager.MenkoList.StopRigidAll();
                currentPlay = playTask;
                currentPlay.Invoke();
            }
            else
            {
                task.Enqueue(playTask);
            }
        }
예제 #20
0
        private IEnumerator <Action> ResolveReferences()
        {
            _aiReferences = new Dictionary <string, AIReference>(StringComparer.Ordinal);
            _referencers  = new List <SceneOrPrefab>();

            //AIs
            var ais = StoredAIs.AIs.ToArray();

            for (int i = 0; i < ais.Length; i++)
            {
                if (_cancelled)
                {
                    yield break;
                }

                _progressMessage = string.Format("Processing AI {0}/{1}: {2}", i, ais.Length, ais[i].name);
                _owner.Repaint();

                yield return(() =>
                {
                    var curAI = GetAIReference(ais[i]);
                    for (int j = 0; j < ais.Length; j++)
                    {
                        if (j == i)
                        {
                            continue;
                        }

                        if (ais[j].configuration.Contains(curAI.id))
                        {
                            var refedBy = GetAIReference(ais[j]);
                            refedBy.directReferences.Add(curAI);
                        }
                    }
                });
            }

            //Scenes
            var scenes = GetScenePaths(_scenes);

            if (scenes == null)
            {
                yield return(() =>
                {
                    var references = GetSceneReferences();
                    CreateSceneOrPrefab(GetCurrentScene(), references, false);
                });
            }
            else
            {
                string curScene = GetCurrentScene();
                for (int i = 0; i < scenes.Length; i++)
                {
                    if (_cancelled)
                    {
                        yield break;
                    }

                    _progressMessage = string.Format("Processing scene {0}/{1}: {2}", i, scenes.Length, scenes[i]);
                    _owner.Repaint();
                    yield return(() =>
                    {
                        OpenScene(scenes[i]);
                        var references = GetSceneReferences();
                        CreateSceneOrPrefab(scenes[i], references, false);
                    });
                }

                OpenScene(curScene);
            }

            //Prefabs
            if (_includePrefabs)
            {
                var prefabs = (from f in Directory.GetFiles(Application.dataPath, "*.prefab", SearchOption.AllDirectories)
                               select AssetPath.ProjectRelativePath(f)).ToArray();

                for (int i = 0; i < prefabs.Length; i++)
                {
                    if (_cancelled)
                    {
                        yield break;
                    }

                    _progressMessage = string.Format("Processing prefab {0}/{1}: {2}", i, prefabs.Length, prefabs[i]);
                    _owner.Repaint();

                    yield return(() =>
                    {
                        var pf = AssetDatabase.LoadMainAssetAtPath(prefabs[i]) as GameObject;
                        if (pf != null)
                        {
                            var references = GetPrefabReferences(pf);
                            CreateSceneOrPrefab(prefabs[i], references, true);
                        }
                    });
                }
            }

            _progressMessage = "Cross referencing";
            _owner.Repaint();
            yield return(() =>
            {
                PrepareAIResult();
            });
        }
예제 #21
0
 protected override void Paste()
 {
     try {
         AssignAsset(AssetPath.CorrectSlashes(Clipboard.Text));
     } catch (System.Exception) { }
 }
예제 #22
0
 private void SetPathPrefix(string oldPrefix, string prefix) =>
 this.SetProperty <T>(current => StringToValueConverter(AssetPath.CorrectSlashes(
                                                            Path.Combine(prefix, ValueToStringConverter(current).Substring(oldPrefix.Length).TrimStart('/')))));
예제 #23
0
        static AssemblyDefintionState LoadAssemblyDefintionState(string path)
        {
            var asset = AssetDatabase.LoadAssetAtPath <AssemblyDefinitionAsset>(path);

            if (asset == null)
            {
                return(null);
            }

            var data = CustomScriptAssemblyData.FromJson(asset.text);

            if (data == null)
            {
                return(null);
            }

            var state = new AssemblyDefintionState();

            state.asset                 = asset;
            state.name                  = data.name;
            state.references            = new List <AssemblyDefinitionReference>();
            state.precompiledReferences = new List <PrecompiledReference>();
            state.defineConstraints     = new List <DefineConstraint>();
            state.autoReferenced        = ToMixedBool(data.autoReferenced);
            state.allowUnsafeCode       = ToMixedBool(data.allowUnsafeCode);
            state.overrideReferences    = ToMixedBool(data.overrideReferences);

            if (data.defineConstraints != null)
            {
                foreach (var defineConstaint in data.defineConstraints)
                {
                    try
                    {
                        var symbolName = defineConstaint.StartsWith(DefineConstraintsHelper.Not) ? defineConstaint.Substring(1) : defineConstaint;
                        if (!SymbolNameRestrictions.IsValid(symbolName))
                        {
                            throw new AssemblyDefinitionException($"Invalid define constraint {symbolName}", path);
                        }

                        state.defineConstraints.Add(new DefineConstraint
                        {
                            name         = defineConstaint,
                            displayValue = MixedBool.False,
                        });
                    }
                    catch (AssemblyDefinitionException e)
                    {
                        Debug.LogException(e, asset);
                        state.modified = true;
                    }
                }
            }

            if (data.references != null)
            {
                foreach (var reference in data.references)
                {
                    try
                    {
                        var assemblyDefinitionFile = new AssemblyDefinitionReference();
                        var referencePath          = Compilation.CompilationPipeline.GetAssemblyDefinitionFilePathFromAssemblyName(reference);

                        if (string.IsNullOrEmpty(referencePath))
                        {
                            throw new AssemblyDefinitionException(string.Format("Could not find assembly reference '{0}'", reference), path);
                        }

                        assemblyDefinitionFile.asset = AssetDatabase.LoadAssetAtPath <AssemblyDefinitionAsset>(referencePath);

                        if (assemblyDefinitionFile.asset == null)
                        {
                            throw new AssemblyDefinitionException(string.Format("Reference assembly definition file '{0}' not found", referencePath), path);
                        }

                        assemblyDefinitionFile.data         = CustomScriptAssemblyData.FromJson(assemblyDefinitionFile.asset.text);
                        assemblyDefinitionFile.displayValue = MixedBool.False;
                        state.references.Add(assemblyDefinitionFile);
                    }
                    catch (AssemblyDefinitionException e)
                    {
                        UnityEngine.Debug.LogException(e, asset);
                        state.references.Add(new AssemblyDefinitionReference());
                        state.modified = true;
                    }
                }
            }

            var nameToPrecompiledReference = EditorCompilationInterface.Instance.GetAllPrecompiledAssemblies()
                                             .Where(x => (x.Flags & AssemblyFlags.UserAssembly) == AssemblyFlags.UserAssembly)
                                             .ToDictionary(x => AssetPath.GetFileName(x.Path), x => x);

            foreach (var precompiledReferenceName in data.precompiledReferences ?? Enumerable.Empty <String>())
            {
                try
                {
                    var precompiledReference = new PrecompiledReference();

                    var precompiledAssemblyPossibleReference = nameToPrecompiledReference.ContainsKey(precompiledReferenceName);
                    if (!precompiledAssemblyPossibleReference && !data.overrideReferences)
                    {
                        throw new AssemblyDefinitionException(string.Format("Referenced precompiled assembly '{0}' not found", precompiledReferenceName), path);
                    }

                    precompiledReference.precompiled  = nameToPrecompiledReference[precompiledReferenceName];
                    precompiledReference.displayValue = MixedBool.True;
                    state.precompiledReferences.Add(precompiledReference);
                }
                catch (AssemblyDefinitionException e)
                {
                    Debug.LogException(e, asset);
                    state.precompiledReferences.Add(new PrecompiledReference());
                    state.modified = true;
                }
            }

            var platforms = CompilationPipeline.GetAssemblyDefinitionPlatforms();

            state.platformCompatibility = new MixedBool[platforms.Length];

            var OptinalUnityAssemblies = CustomScriptAssembly.OptinalUnityAssemblies;

            state.optionalUnityReferences = new MixedBool[OptinalUnityAssemblies.Length];

            if (data.optionalUnityReferences != null)
            {
                for (int i = 0; i < OptinalUnityAssemblies.Length; i++)
                {
                    var optionalUnityReferences = OptinalUnityAssemblies[i].OptionalUnityReferences.ToString();
                    var any = data.optionalUnityReferences.Any(x => x == optionalUnityReferences);
                    if (any)
                    {
                        state.optionalUnityReferences[i] = MixedBool.True;
                    }
                }
            }

            state.compatibleWithAnyPlatform = MixedBool.True;
            string[] dataPlatforms = null;

            if (data.includePlatforms != null && data.includePlatforms.Length > 0)
            {
                state.compatibleWithAnyPlatform = MixedBool.False;
                dataPlatforms = data.includePlatforms;
            }
            else if (data.excludePlatforms != null && data.excludePlatforms.Length > 0)
            {
                state.compatibleWithAnyPlatform = MixedBool.True;
                dataPlatforms = data.excludePlatforms;
            }

            if (dataPlatforms != null)
            {
                foreach (var platform in dataPlatforms)
                {
                    var platformIndex = GetPlatformIndex(platforms, platform);
                    state.platformCompatibility[platformIndex] = MixedBool.True;
                }
            }

            return(state);
        }
예제 #24
0
        public void Start()
        {
            Console.WriteLine("Generating scenes code for {0} scenes...", scenesForProcessing.Count);
            var generatedScenesPath = $"{directory}/{projectName}.GeneratedScenes";

            if (!Directory.Exists(generatedScenesPath))
            {
                GenerateProjectFiles(generatedScenesPath);
            }
            var scenesPath = $@"{directory}/{projectName}.GeneratedScenes/Scenes";

            RemoveOrphanedGeneratedCodeItems();
            RemoveUpdatingCommonPartsFromCache();
            foreach (var scenePath in allScenes)
            {
                externalSceneToOriginalScenePath.Add(Path.ChangeExtension(scenePath, null), scenePath);
            }
            var sceneToFrameTree = new List <Tuple <string, ParsedFramesTree> >();

            foreach (var scene in scenesForProcessing)
            {
                var bundleName       = sceneToBundleMap[scene.Key];
                var bundleSourcePath = $"{scenesPath}/{bundleName}";
                if (!Directory.Exists(bundleSourcePath))
                {
                    RetryUntilSuccessCreateDirectory(bundleSourcePath);
                }
                currentCookingScene = scene.Key;
                var parsedFramesTree = GenerateParsedFramesTree(scene.Key, scene.Value);
                sceneToFrameTree.Add(new Tuple <string, ParsedFramesTree>(scene.Key, parsedFramesTree));
            }
            foreach (var kv in sceneToFrameTree)
            {
                var parsedFramesTree = kv.Item2;
                currentCookingScene = kv.Item1;
                var k = Path.ChangeExtension(kv.Item1, null);
                k = AssetPath.CorrectSlashes(k);
                var id                = scenesForProcessing[kv.Item1].Id;
                var bundleName        = sceneToBundleMap[kv.Item1];
                var bundleSourcePath  = $"{scenesPath}/{bundleName}";
                var generatedCodePath = bundleSourcePath + "/" + parsedFramesTree.ClassName + ".cs";
                var useful            =
                    parsedFramesTree.ParsedNodes.Count > 0 ||
                    parsedFramesTree.InnerClasses.Count > 0 ||
                    (id != null && (id.StartsWith("@") || id.StartsWith(">")));
                if (!useful)
                {
                    if (File.Exists(generatedCodePath))
                    {
                        File.Delete(generatedCodePath);
                    }
                    continue;
                }
                var code = parsedFramesTree.GenerateCode(this);
                code = code.Replace("<%PROJECT_NAME%>", projectName);
                code = code.Replace("<%NAMESPACE%>", GetBundleNamespace(bundleName));
                code = new CodeFormatter(code).FormattedCode;
                File.WriteAllText(generatedCodePath, code);
            }
            UpdateCache();
            // Collect not loaded scenes which are also contains common parts affected by actually modified and referred to them scenes
            // Because we need those to correctly update common parts. i.e. to calc common parts you need all of common parts referrers
            List <string> reprocessScenes = new List <string>();

            foreach (var kv in codeCookerCache.CommonPartToReferredScenes)
            {
                if (commonParts.ContainsKey(kv.Key))
                {
                    foreach (var scene in kv.Value)
                    {
                        if (!modifiedScenes.Contains(scene))
                        {
                            reprocessScenes.Add(scene);
                        }
                    }
                }
            }
            foreach (var scene in reprocessScenes)
            {
                GenerateParsedFramesTree(scene, Node.CreateFromAssetBundle(scene));
            }
            GenerateCommonParts(scenesPath);
            UpdateCommonPartsCache();
        }
        public override bool Execute()
        {
            Log.LogMessage($"Copying static web assets to blazor project via task...");
            try
            {
                foreach (string projectName in ProjectsWithStaticFiles)
                {
                    if (AssetPath.Contains(projectName))
                    {
                        var fileName   = Path.GetFileName(AssetPath);
                        var folderName = $"{TargetPath}/_content/{projectName}/";
                        var sourcePath = AssetPath.Replace(fileName, "");

                        if (!Directory.Exists(folderName))
                        {
                            Directory.CreateDirectory(folderName);
                        }

                        // copy all directories
                        foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories))
                        {
                            Directory.CreateDirectory(dirPath.Replace(sourcePath, folderName));
                        }

                        // copy all files
                        foreach (string filePath in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories))
                        {
                            File.Copy(filePath, filePath.Replace(sourcePath, folderName), true);
                        }

                        if (File.Exists(JsImportsPath))
                        {
                            var jsImports        = JsonConvert.DeserializeObject <List <string> >(File.ReadAllText(JsImportsPath));
                            var indexTsxFielPath = $"{TargetPath}/index.tsx";
                            var jsImportsString  = "";
                            foreach (var jsImport in jsImports)
                            {
                                if (!File.ReadAllText(indexTsxFielPath).Contains($"import '{jsImport}';"))
                                {
                                    jsImportsString += $"import '{jsImport}';\n";
                                }
                            }
                            File.WriteAllText(indexTsxFielPath, jsImportsString + File.ReadAllText(indexTsxFielPath));
                        }
                        else
                        {
                            Log.LogError($"The file '{JsImportsPath}' does not exist.");
                        }

                        Log.LogMessage($"'{AssetPath}' copied to '{folderName}'.");
                    }
                }
            }
            catch (Exception error)
            {
                Log.LogError(error.Message);
                return(false);
            }

            return(true);
        }
예제 #26
0
        public DiskSelector(Screen screen, string initialDiskPath, Mod initialDiskMod, Progress progress)
        {
            m_geometry      = new Geometry(Primitive.Triangles);
            m_disks         = ArcadeUtils.GetAllDisks().ToArray();
            m_disksUnlocked = m_disks.Select(disk => ArcadeUtils.IsDiskUnlocked(disk.Disk, disk.Mod, progress)).ToArray();

            m_page = 0;
            if (m_disks.Length <= COLUMNS_PER_PAGE)
            {
                m_numColumns = m_disks.Length;
                m_numRows    = 1;
            }
            else if (m_disks.Length < NUM_PER_PAGE)
            {
                m_numColumns = (m_disks.Length + ROWS_PER_PAGE - 1) / ROWS_PER_PAGE;
                m_numRows    = ROWS_PER_PAGE;
            }
            else
            {
                m_numColumns = COLUMNS_PER_PAGE;
                m_numRows    = ROWS_PER_PAGE;
            }
            m_highlight = -1;

            m_backPrompt                       = new InputPrompt(UIFonts.Smaller, screen.Language.Translate("menus.close"), TextAlignment.Right);
            m_backPrompt.Key                   = Key.Escape;
            m_backPrompt.MouseButton           = MouseButton.Left;
            m_backPrompt.GamepadButton         = GamepadButton.B;
            m_backPrompt.SteamControllerButton = SteamControllerButton.MenuBack;
            m_backPrompt.Anchor                = Anchor.BottomRight;
            m_backPrompt.LocalPosition         = new Vector2(-16.0f, -16.0f - m_backPrompt.Height);
            m_backPrompt.Parent                = this;
            m_backPrompt.OnClick              += delegate(object o, EventArgs args)
            {
                m_closeNextFrame = true;
            };

            m_selectPrompt                       = new InputPrompt(UIFonts.Smaller, screen.Language.Translate("menus.select"), TextAlignment.Left);
            m_selectPrompt.Key                   = Key.Return;
            m_selectPrompt.GamepadButton         = GamepadButton.A;
            m_selectPrompt.SteamControllerButton = SteamControllerButton.MenuSelect;
            m_selectPrompt.Anchor                = Anchor.BottomLeft;
            m_selectPrompt.LocalPosition         = new Vector2(16.0f, -16.0f - m_selectPrompt.Height);
            m_selectPrompt.Parent                = this;

            m_browseWorkshopPrompt                       = new InputPrompt(UIFonts.Smaller, screen.Language.Translate("menus.arcade.browse_workshop"), TextAlignment.Right);
            m_browseWorkshopPrompt.Key                   = Key.LeftCtrl;
            m_browseWorkshopPrompt.GamepadButton         = GamepadButton.Y;
            m_browseWorkshopPrompt.SteamControllerButton = SteamControllerButton.MenuAltSelect;
            m_browseWorkshopPrompt.Anchor                = Anchor.BottomRight;
            m_browseWorkshopPrompt.LocalPosition         = new Vector2(-16.0f, -16.0f - m_selectPrompt.Height - m_browseWorkshopPrompt.Height);
            m_browseWorkshopPrompt.Parent                = this;

            m_previousPageButton                               = new Button(Texture.Get("gui/arrows.png", true), 32.0f, 32.0f);
            m_previousPageButton.Region                        = new Quad(0.0f, 0.5f, 0.5f, 0.5f);
            m_previousPageButton.HighlightRegion               = m_previousPageButton.Region;
            m_previousPageButton.DisabledRegion                = m_previousPageButton.Region;
            m_previousPageButton.ShortcutButton                = GamepadButton.LeftBumper;
            m_previousPageButton.AltShortcutButton             = GamepadButton.LeftTrigger;
            m_previousPageButton.ShortcutSteamControllerButton = SteamControllerButton.MenuPreviousPage;
            m_previousPageButton.Colour                        = UIColours.Title;
            m_previousPageButton.HighlightColour               = UIColours.White;
            m_previousPageButton.DisabledColour                = m_previousPageButton.Colour;
            m_previousPageButton.Anchor                        = Anchor.CentreMiddle;
            m_previousPageButton.LocalPosition                 = new Vector2(
                -0.5f * (float)COLUMNS_PER_PAGE * (DISK_SIZE + DISK_PADDING) - m_previousPageButton.Width,
                -0.5f * m_previousPageButton.Height
                );
            m_previousPageButton.Parent     = this;
            m_previousPageButton.OnClicked += delegate(object o, EventArgs e)
            {
                PreviousPage();
            };

            m_nextPageButton                               = new Button(Texture.Get("gui/arrows.png", true), 32.0f, 32.0f);
            m_nextPageButton.Region                        = new Quad(0.0f, 0.0f, 0.5f, 0.5f);
            m_nextPageButton.HighlightRegion               = m_nextPageButton.Region;
            m_nextPageButton.DisabledRegion                = m_nextPageButton.Region;
            m_nextPageButton.ShortcutButton                = GamepadButton.RightBumper;
            m_nextPageButton.AltShortcutButton             = GamepadButton.RightTrigger;
            m_nextPageButton.ShortcutSteamControllerButton = SteamControllerButton.MenuNextPage;
            m_nextPageButton.Colour                        = UIColours.Title;
            m_nextPageButton.HighlightColour               = UIColours.White;
            m_nextPageButton.DisabledColour                = m_nextPageButton.Colour;
            m_nextPageButton.Anchor                        = Anchor.CentreMiddle;
            m_nextPageButton.LocalPosition                 = new Vector2(
                0.5f * (float)COLUMNS_PER_PAGE * (DISK_SIZE + DISK_PADDING),
                -0.5f * m_previousPageButton.Height
                );
            m_nextPageButton.Parent     = this;
            m_nextPageButton.OnClicked += delegate(object o, EventArgs e)
            {
                NextPage();
            };

            // Load labels
            m_diskLabels = new Texture[m_disks.Length];
            for (int i = 0; i < m_disks.Length; ++i)
            {
                var disk      = m_disks[i];
                var labelPath = AssetPath.ChangeExtension(disk.Disk.Path, "png");
                if (disk.Mod != null)
                {
                    if (disk.Mod.Assets.CanLoad(labelPath))
                    {
                        m_diskLabels[i]        = disk.Mod.Assets.Load <Texture>(labelPath);
                        m_diskLabels[i].Filter = false;
                    }
                }
                else
                {
                    m_diskLabels[i] = Texture.Get(labelPath, false);
                }
            }

            m_framesOpen     = 0;
            m_closeNextFrame = false;

            // Determine initial disk index
            m_initialDisk = -1;
            if (initialDiskPath != null && m_disks.Length > 0)
            {
                for (int i = 0; i < m_disks.Length; ++i)
                {
                    var disk = m_disks[i];
                    if (disk.Disk.Path == initialDiskPath &&
                        disk.Mod == initialDiskMod &&
                        m_disksUnlocked[i])
                    {
                        m_initialDisk = i;
                        break;
                    }
                }
            }
        }
예제 #27
0
 public AssetFile Find(AssetPath path)
 {
     throw new NotImplementedException();
 }
예제 #28
0
        private List<AssetPath> GenerateAssetList(string contentPath)
        {
            string appPath = Application.dataPath.Substring(0, Application.dataPath.LastIndexOf(@"Assets"));
            var lst = new List<AssetPath>();
            var directoryInfo = new DirectoryInfo(contentPath).GetDirectories();
            foreach (var item in directoryInfo)
            {
                string pathnameFromFile = File.ReadAllLines(Path.Combine(item.FullName, "pathname")).ToList().First();
                //ensure path correction
                pathnameFromFile = pathnameFromFile.Replace(@"\\", "/");
                pathnameFromFile = pathnameFromFile.Replace(@"\", "/");

                var asset = new AssetPath();
                if (Directory.Exists(Path.Combine(appPath, pathnameFromFile)))
                {
                    asset.name = Path.GetDirectoryName(pathnameFromFile);

                    if (!pathnameFromFile.EndsWith("/"))
                    {
                        pathnameFromFile += "/";
                    }
                }
                else
                {
                    asset.name = Path.GetFileName(pathnameFromFile);
                }
                asset.filePath = pathnameFromFile;

                lst.Add(asset);
            }
            var ordered = lst.OrderByDescending(i => i.filePath.Count(x => x == '/'));

            return ordered.ToList();
        }
        static void LoadAssemblyDefintionState(AssemblyDefinitionState state, string path)
        {
            var asset = AssetDatabase.LoadAssetAtPath <AssemblyDefinitionAsset>(path);

            if (asset == null)
            {
                return;
            }

            var data = CustomScriptAssemblyData.FromJsonNoFieldValidation(asset.text);

            if (data == null)
            {
                return;
            }

            try
            {
                data.ValidateFields();
            }
            catch (Exception e)
            {
                Debug.LogException(e, asset);
            }

            state.asset                 = asset;
            state.assemblyName          = data.name;
            state.references            = new List <AssemblyDefinitionReference>();
            state.precompiledReferences = new List <PrecompiledReference>();
            state.defineConstraints     = new List <DefineConstraint>();
            state.versionDefines        = new List <VersionDefine>();
            state.autoReferenced        = data.autoReferenced;
            state.allowUnsafeCode       = data.allowUnsafeCode;
            state.overrideReferences    = data.overrideReferences;

            // If the .asmdef has no references (true for newly created .asmdef), then use GUIDs.
            // Otherwise do not use GUIDs. This value might be changed below if any reference is a GUID.
            state.useGUIDs = (data.references == null || data.references.Length == 0);

            if (data.versionDefines != null)
            {
                foreach (var versionDefine in data.versionDefines)
                {
                    if (!SymbolNameRestrictions.IsValid(versionDefine.define))
                    {
                        var exception = new AssemblyDefinitionException($"Invalid version define {versionDefine.define}", path);
                        Debug.LogException(exception, asset);
                    }
                    else
                    {
                        state.versionDefines.Add(new VersionDefine
                        {
                            name       = versionDefine.name,
                            expression = versionDefine.expression,
                            define     = versionDefine.define,
                        });
                    }
                }
            }

            if (data.defineConstraints != null)
            {
                foreach (var defineConstraint in data.defineConstraints)
                {
                    var symbolName = defineConstraint.StartsWith(DefineConstraintsHelper.Not) ? defineConstraint.Substring(1) : defineConstraint;
                    if (!SymbolNameRestrictions.IsValid(symbolName))
                    {
                        var exception = new AssemblyDefinitionException($"Invalid define constraint {symbolName}", path);
                        Debug.LogException(exception, asset);
                    }
                    else
                    {
                        state.defineConstraints.Add(new DefineConstraint
                        {
                            name = defineConstraint,
                        });
                    }
                }
            }

            if (data.references != null)
            {
                foreach (var reference in data.references)
                {
                    try
                    {
                        var assemblyDefinitionFile = new AssemblyDefinitionReference
                        {
                            name = reference,
                            serializedReference = reference
                        };

                        // If any references is a GUID, use GUIDs.
                        var isGuid = CompilationPipeline.GetAssemblyDefinitionReferenceType(reference) == AssemblyDefinitionReferenceType.Guid;
                        if (isGuid)
                        {
                            state.useGUIDs = true;
                        }

                        assemblyDefinitionFile.Load(reference, isGuid);
                        state.references.Add(assemblyDefinitionFile);
                    }
                    catch (AssemblyDefinitionException e)
                    {
                        UnityEngine.Debug.LogException(e, asset);
                        state.references.Add(new AssemblyDefinitionReference());
                    }
                }
            }

            var nameToPrecompiledReference = EditorCompilationInterface.Instance.GetAllPrecompiledAssemblies()
                                             .Where(x => (x.Flags & AssemblyFlags.UserAssembly) == AssemblyFlags.UserAssembly)
                                             .ToDictionary(x => AssetPath.GetFileName(x.Path), x => x);

            foreach (var precompiledReferenceName in data.precompiledReferences ?? Enumerable.Empty <String>())
            {
                try
                {
                    var precompiledReference = new PrecompiledReference
                    {
                        name = precompiledReferenceName,
                    };

                    PrecompiledAssembly assembly;
                    if (nameToPrecompiledReference.TryGetValue(precompiledReferenceName, out assembly))
                    {
                        precompiledReference.path     = assembly.Path;
                        precompiledReference.fileName = AssetPath.GetFileName(assembly.Path);
                    }
                    state.precompiledReferences.Add(precompiledReference);
                }
                catch (AssemblyDefinitionException e)
                {
                    Debug.LogException(e, asset);
                    state.precompiledReferences.Add(new PrecompiledReference());
                }
            }

            var platforms = CompilationPipeline.GetAssemblyDefinitionPlatforms();

            state.platformCompatibility = new bool[platforms.Length];

            state.compatibleWithAnyPlatform = true;
            string[] dataPlatforms = null;

            if (data.includePlatforms != null && data.includePlatforms.Length > 0)
            {
                state.compatibleWithAnyPlatform = false;
                dataPlatforms = data.includePlatforms;
            }
            else if (data.excludePlatforms != null && data.excludePlatforms.Length > 0)
            {
                state.compatibleWithAnyPlatform = true;
                dataPlatforms = data.excludePlatforms;
            }

            if (dataPlatforms != null)
            {
                foreach (var platform in dataPlatforms)
                {
                    var platformIndex = GetPlatformIndex(platforms, platform);
                    state.platformCompatibility[platformIndex] = true;
                }
            }
        }
예제 #30
0
        // pass target as null to build cooking rules disregarding targets
        public static Dictionary <string, CookingRules> Build(IFileEnumerator fileEnumerator, Target target)
        {
            var shouldRescanEnumerator = false;
            var pathStack  = new Stack <string>();
            var rulesStack = new Stack <CookingRules>();
            var map        = new Dictionary <string, CookingRules>();

            pathStack.Push("");
            var rootRules = new CookingRules();

            rootRules.DeduceEffectiveRules(target);
            rulesStack.Push(rootRules);
            using (new DirectoryChanger(fileEnumerator.Directory)) {
                foreach (var fileInfo in fileEnumerator.Enumerate())
                {
                    var path = fileInfo.Path;
                    while (!path.StartsWith(pathStack.Peek()))
                    {
                        rulesStack.Pop();
                        pathStack.Pop();
                    }
                    if (Path.GetFileName(path) == CookingRulesFilename)
                    {
                        var dirName = Lime.AssetPath.GetDirectoryName(path);
                        pathStack.Push(dirName == string.Empty ? "" : dirName + "/");
                        var rules = ParseCookingRules(rulesStack.Peek(), path, target);
                        rules.SourceFilename = AssetPath.Combine(fileEnumerator.Directory, path);
                        rulesStack.Push(rules);
                        // Add 'ignore' cooking rules for this #CookingRules.txt itself
                        var ignoreRules = rules.InheritClone();
                        ignoreRules.Ignore = true;
                        map[path]          = ignoreRules;
                        var directoryName = pathStack.Peek();
                        if (!string.IsNullOrEmpty(directoryName))
                        {
                            directoryName = directoryName.Remove(directoryName.Length - 1);
                            // it is possible for map to not contain this directoryName since not every IFileEnumerator enumerates directories
                            if (map.ContainsKey(directoryName))
                            {
                                map[directoryName] = rules;
                            }
                        }
                    }
                    else
                    {
                        if (Path.GetExtension(path) == ".txt")
                        {
                            var filename = path.Remove(path.Length - 4);
                            if (File.Exists(filename) || Directory.Exists(filename))
                            {
                                continue;
                            }
                        }
                        var rulesFile = path + ".txt";
                        var rules     = rulesStack.Peek();
                        if (File.Exists(rulesFile))
                        {
                            rules = ParseCookingRules(rulesStack.Peek(), rulesFile, target);
                            rules.SourceFilename = AssetPath.Combine(fileEnumerator.Directory, rulesFile);
                            // Add 'ignore' cooking rules for this cooking rules text file
                            var ignoreRules = rules.InheritClone();
                            ignoreRules.Ignore = true;
                            map[rulesFile]     = ignoreRules;
                        }
                        if (rules.CommonRules.LastChangeTime > fileInfo.LastWriteTime)
                        {
                            try {
                                File.SetLastWriteTime(path, rules.CommonRules.LastChangeTime);
                            } catch (UnauthorizedAccessException) {
                                // In case this is a folder
                            }
                            shouldRescanEnumerator = true;
                        }
                        map[path] = rules;
                    }
                }
            }
            if (shouldRescanEnumerator)
            {
                fileEnumerator.Rescan();
            }
            return(map);
        }
        internal static string GenerateResponseFile(ScriptAssembly assembly, string tempBuildDirectory)
        {
            var assemblyOutputPath = PrepareFileName(AssetPath.Combine(tempBuildDirectory, assembly.Filename));

            var arguments = new List <string>
            {
                "/target:library",
                "/nowarn:0169",
                "/out:" + assemblyOutputPath
            };

            if (assembly.CompilerOptions.AllowUnsafeCode)
            {
                arguments.Add("/unsafe");
            }

            if (assembly.CompilerOptions.UseDeterministicCompilation)
            {
                arguments.Add("/deterministic");
            }

            arguments.Add("/debug:portable");

            if (assembly.CompilerOptions.CodeOptimization == CodeOptimization.Release)
            {
                arguments.Add("/optimize+");
            }
            else
            {
                arguments.Add("/optimize-");
            }

            FillCompilerOptions(arguments, assembly.BuildTarget);

            string[] scriptAssemblyReferences = new string[assembly.ScriptAssemblyReferences.Length];
            for (var index = 0; index < assembly.ScriptAssemblyReferences.Length; index++)
            {
                var reference = assembly.ScriptAssemblyReferences[index];
                scriptAssemblyReferences[index] = "/reference:" +
                                                  PrepareFileName(AssetPath.Combine(assembly.OutputDirectory,
                                                                                    reference.Filename));
            }
            Array.Sort(scriptAssemblyReferences, StringComparer.Ordinal);
            arguments.AddRange(scriptAssemblyReferences);

            Array.Sort(assembly.References, StringComparer.Ordinal);
            foreach (var reference in assembly.References)
            {
                arguments.Add("/reference:" + PrepareFileName(reference));
            }

            var defines = assembly.Defines.Distinct().ToArray();

            Array.Sort(defines, StringComparer.Ordinal);
            foreach (var define in defines)
            {
                arguments.Add("/define:" + define);
            }

            Array.Sort(assembly.Files, StringComparer.Ordinal);
            foreach (var source in assembly.Files)
            {
                var f = PrepareFileName(source);
                f = Paths.UnifyDirectorySeparator(f);
                arguments.Add(f);
            }

            var responseFileProvider       = assembly.Language?.CreateResponseFileProvider();
            var responseFilesList          = responseFileProvider?.Get(assembly.OriginPath) ?? new List <string>();
            HashSet <string> responseFiles = new HashSet <string>(responseFilesList);

            string obsoleteResponseFile = responseFiles.SingleOrDefault(
                x => CompilerSpecificResponseFiles.MicrosoftCSharpCompilerObsolete.Contains(AssetPath.GetFileName(x)));

            if (!string.IsNullOrEmpty(obsoleteResponseFile))
            {
                Debug.LogWarning($"Using obsolete custom response file '{AssetPath.GetFileName(obsoleteResponseFile)}'. Please use '{CompilerSpecificResponseFiles.MicrosoftCSharpCompiler}' instead.");
            }

            foreach (var file in responseFiles)
            {
                AddResponseFileToArguments(arguments, file, assembly.CompilerOptions.ApiCompatibilityLevel);
            }

            var responseFile = CommandLineFormatter.GenerateResponseFile(arguments);

            return(responseFile);
        }
예제 #32
0
        private bool ChangeStorageFolder(string proposedFolder)
        {
            if (string.Equals(proposedFolder, _storagePath, StringComparison.OrdinalIgnoreCase) || !AssetPath.IsProjectPath(proposedFolder))
            {
                return(false);
            }

            proposedFolder = AssetPath.ProjectRelativePath(proposedFolder);
            bool apexified = proposedFolder.EndsWith("Resources/" + AIManager.StorageFolder);

            if (!proposedFolder.EndsWith("Resources") && !apexified)
            {
                EditorUtility.DisplayDialog("Invalid Storage Folder", "The storage folder selected must be a Resources folder. This can however be anywhere inside the Assets folder.", "Ok");
                return(false);
            }

            if (!apexified)
            {
                proposedFolder = AssetPath.Combine(proposedFolder, AIManager.StorageFolder);
            }

            AssetPath.EnsurePath(proposedFolder);

            //Move files from current storage location to new location.
            var fullStoragePath = AssetPath.GetFullPath(_storagePath);

            if (Directory.Exists(fullStoragePath))
            {
                foreach (var asset in Directory.GetFiles(fullStoragePath, "*.asset", SearchOption.TopDirectoryOnly))
                {
                    var fileName = Path.GetFileName(asset);
                    var msg      = AssetDatabase.MoveAsset(AssetPath.ProjectRelativePath(asset), AssetPath.Combine(proposedFolder, fileName));
                    if (!string.IsNullOrEmpty(msg))
                    {
                        EditorUtility.DisplayDialog("Error Moving Assets", msg, "Ok");
                        return(false);
                    }
                }

                AssetDatabase.DeleteAsset(_storagePath);
            }

            _storagePath = proposedFolder;

            return(true);
        }