示例#1
0
        /// <summary>
        ///     Adds a folder to the passed COCDomain at the relative path starting from the Unity Assets folder, Game Asset Root,
        ///     and down the array of subfolders corresponding to args.
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="args"></param>
        public static void AddGameConvention(COCDomain domain, params string[] args)
        {
            // If no folder names were provided, return.
            if (args.Length == 0)
            {
                return;
            }

            var relativeFolderPath = COCUtility.GetGamePath(domain, args);
            var absoluteFolderPath = Path.Combine(COCUtility.GetUnityAssetRoot(), relativeFolderPath);

            if (!Directory.Exists(absoluteFolderPath))
            {
                Directory.CreateDirectory(absoluteFolderPath);

                Debug.LogFormat("[COC] Folder created at \"{0}\"", absoluteFolderPath);
            }

            COCUtility.PreserveFolder(relativeFolderPath);
        }
示例#2
0
        /// <summary>
        ///     EnsureSetup will rerun the AddConvention initialization process to create the necessary folder
        ///     desired by the project, tools, and frameworks reliant on it.
        /// </summary>
        public static void EnsureSetup()
        {
            // Initialize any root domain folders and paths
            if (!Directory.Exists(Path.Combine(COCUtility.GetUnityAssetRoot(), COCUtility.GAME_ASSET_ROOT)))
            {
                COCUtility.CreateGameRoot();
            }

            var allCOCDomains = (COCDomain[])Enum.GetValues(typeof(COCDomain));

            foreach (var cocDomain in allCOCDomains)
            {
                var relativeFolderPath = COCUtility.GetGamePath(cocDomain);
                var absoluteFolderPath = Path.Combine(COCUtility.GetUnityAssetRoot(), relativeFolderPath);
                if (!Directory.Exists(absoluteFolderPath))
                {
                    Directory.CreateDirectory(absoluteFolderPath);

                    Debug.LogFormat("[COC] Folder created at \"{0}\"", absoluteFolderPath);
                }

                COCUtility.PreserveFolder(COCUtility.GetGamePath(cocDomain));
            }

            // Set the scripting symbol for COC
            PlayerSettingsUtility.AddScriptingSymbolIfNotDefined(SCRIPTING_SYMBOL);

            // Search through the project for all derived classes of COCProviderBase
            // and add their conventions to the project
            var cocProviders = ReflectionUtility.GetAllDerivedInstancesOfType <COCProviderBase>();

            foreach (var cocProvider in cocProviders)
            {
                cocProvider.AddConventions();
            }

            AssetDatabase.Refresh();
        }