コード例 #1
0
 public void Initialize(EntitasPreferencesConfig config)
 {
     _visualDebuggingConfig = new VisualDebuggingConfig(config);
     _scriptingDefineSymbols = new ScriptingDefineSymbols();
     _enableVisualDebugging = !_scriptingDefineSymbols.buildTargetToDefSymbol.Values
         .All<string>(defs => defs.Contains(ENTITAS_DISABLE_VISUAL_DEBUGGING));
 }
コード例 #2
0
 public void Initialize(EntitasPreferencesConfig config)
 {
     _visualDebuggingConfig  = new VisualDebuggingConfig(config);
     _scriptingDefineSymbols = new ScriptingDefineSymbols();
     _enableVisualDebugging  = !_scriptingDefineSymbols.buildTargetToDefSymbol.Values
                               .All <string>(defs => defs.Contains(ENTITAS_DISABLE_VISUAL_DEBUGGING));
 }
コード例 #3
0
        private void SetScriptingDefineSymbols(BuildTargetGroup targetGroup)
        {
            ScriptingDefineSymbols scriptingDefineSymbols = new ScriptingDefineSymbols(PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup));

            if (_useSpine.value)
            {
                scriptingDefineSymbols.AddSymbol("USE_SPINE");
            }
            else
            {
                scriptingDefineSymbols.RemoveSymbol("USE_SPINE");
            }

            if (_useDOTween.value)
            {
                scriptingDefineSymbols.AddSymbol("USE_DOTWEEN");
            }
            else
            {
                scriptingDefineSymbols.RemoveSymbol("USE_DOTWEEN");
            }

            if (_useNetworking.value)
            {
                scriptingDefineSymbols.AddSymbol("USE_NETWORKING");
            }
            else
            {
                scriptingDefineSymbols.RemoveSymbol("USE_NETWORKING");
            }

            PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, scriptingDefineSymbols.ToString());
        }
コード例 #4
0
 /// <summary>
 /// Performs any needed setup or initialization prior to drawing user preferences
 /// </summary>
 public override void Initialize()
 {
     _scriptingDefineSymbols = new ScriptingDefineSymbols();
     _enableVisualDebugging  = !_scriptingDefineSymbols.BuildTargetToDefSymbol.Values
                               .All(defs => defs.Contains(ENTITAS_DISABLE_VISUAL_DEBUGGING));
     _enableDeviceDeepProfiling = !_scriptingDefineSymbols.BuildTargetToDefSymbol.Values
                                  .All(defs => defs.Contains(ENTITAS_DISABLE_DEEP_PROFILING));
 }
コード例 #5
0
        public override void Initialize(Preferences preferences)
        {
            _visualDebuggingConfig = preferences.CreateAndConfigure <VisualDebuggingConfig>();
            preferences.properties.AddProperties(_visualDebuggingConfig.defaultProperties, false);

            _scriptingDefineSymbols = new ScriptingDefineSymbols();
            _enableVisualDebugging  = !_scriptingDefineSymbols.buildTargetToDefSymbol.Values
                                      .All <string>(defs => defs.Contains(ENTITAS_DISABLE_VISUAL_DEBUGGING));
        }
コード例 #6
0
 private static void SetHotfixTypeInternal()
 {
     for (int i = 0; i < HotfixTypes.Length; i++)
     {
         if (i == 2)
         {
             ScriptingDefineSymbols.AddScriptingDefineSymbol(HotfixTypes[i]);
         }
         else
         {
             ScriptingDefineSymbols.RemoveScriptingDefineSymbol(HotfixTypes[i]);
         }
     }
 }
コード例 #7
0
    public static void ModifyScriptingDefineSymbol(ScriptingDefineSymbols defineSymbol, bool doAdd, bool userAction = false, bool dependenciesCall = false)
    {
        string value = defineSymbol.ToString();

        // This must be done before any ModifyPlugins calls or we'll end up displaying the main action AFTER fixing dependencies which is reversed
        if (!doAdd && (EditorApplication.isCompiling || EditorApplication.isUpdating))
        {
            DisplayProgressBar(doAdd, dependenciesCall, value);
        }

        // If we're adding the plugin then do it before we set the scripting define symbol
        // (or script errors will be thrown as scripts interact with the plugin again)
        if (doAdd)
        {
            ModifyPlugins(value, doAdd, userAction);
        }

        string newScriptingDefines = "";

        newScriptingDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);

        if (doAdd)
        {
            // Only add it if it doesn't already exist
            if (!newScriptingDefines.Contains(value))
            {
                newScriptingDefines += ";" + value;                 // If the ; isn't required Unity automatically removes it for us :)
            }
        }
        else
        {
            newScriptingDefines = newScriptingDefines.Replace(value, "");              // Unity will automatically remove any left over ; separators for us
        }

        PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, newScriptingDefines);

        // If we're removing the plugin then do it once the scripting define symbol has been removed
        // (so we don't get script errors complaining about the plugin being missing before the scripts are disabled)
        if (!doAdd)
        {
            ModifyPlugins(value, doAdd, userAction);
        }
    }
コード例 #8
0
    private static void ModifyPlugins(string value, bool doAdd, bool userAction = false)
    {
        ProjectManager.AdvLog("Modifying plugins: " + value + ", " + doAdd + ", " + userAction);

        // If this is an add action this must be done before any scripting defines are changed
        if (doAdd && (EditorApplication.isCompiling || EditorApplication.isUpdating))
        {
            DisplayProgressBar(doAdd, false, value);
        }

        // Move plugins not in use outside of the assets folder
        // (I was just going to change their import platform settings but it was a pain to manage them for different platforms
        // so just keeping defaults and moving out of the assets folder will be fine + cleaner project with less projects active)
        List <string> activePlatformPluginFiles = GetPluginFiles(value, EditorUserBuildSettings.selectedBuildTargetGroup, true);
        List <string> otherPlatformPluginFiles  = GetPluginFiles(value, EditorUserBuildSettings.selectedBuildTargetGroup, false);

        string projectPath         = Application.dataPath.Replace("/Assets", ""); // Absolute path to the project with Assets folder removed e.g C:/Projects/My Game
        string disabledPluginsPath = projectPath + "/Disabled Plugins";           // C:/Projects/My Game/Disabled Plugins

        // Make sure the Disabled Plugins folder exists
        if (!Directory.Exists(disabledPluginsPath))
        {
            Directory.CreateDirectory(disabledPluginsPath);
        }

        if (Directory.Exists(disabledPluginsPath))
        {
            // Move plugins files for other platforms out of the project
            if (otherPlatformPluginFiles.Count > 0)
            {
                ProjectManager.AdvLog("There are " + otherPlatformPluginFiles.Count + " other plugin files to move out of the project!");

                foreach (string file in otherPlatformPluginFiles)
                {
                    ProjectManager.AdvLog("Moving " + file + " out of project!");

                    string insideProjectPath  = "Assets/" + file;
                    string outsideProjectPath = file;

                    // Run GetAttributes within a try catch or if the file doesn't exist it'll throw an error (and we're calling this in the first place to see if the file exists ;_;)
                    try {
                        // Are we moving a directory or just a file?
                        bool isDir = File.GetAttributes(projectPath + "/" + insideProjectPath) == FileAttributes.Directory;

                        // Before we bother calculating any moving or folder creation check if the files we want to move out of the project are actually in the project already
                        if (!isDir)
                        {
                            if (File.Exists(projectPath + "/" + insideProjectPath))
                            {
                                // Get each folder as an array from the new file path so we can create all the nessesary folders
                                string[] splitOutsidePath = outsideProjectPath.Split("/" [0]);                                  // ["Plugins", "Android", "Example.aar"]
                                string   curPath          = "";

                                // Minus 1 from the total iteration because the last value will be the actual file
                                for (int i = 0; i < splitOutsidePath.Length - 1; i++)
                                {
                                    curPath += "/" + splitOutsidePath [i];

                                    if (!Directory.Exists(disabledPluginsPath + curPath))
                                    {
                                        Directory.CreateDirectory(disabledPluginsPath + curPath);
                                    }
                                }

                                // All the folders should now be created and the files can be moved
                                MoveFile(projectPath + "/" + insideProjectPath, disabledPluginsPath + "/" + outsideProjectPath);
                                MoveFile(projectPath + "/" + insideProjectPath + ".meta", disabledPluginsPath + "/" + outsideProjectPath + ".meta");
                            }
                            else
                            {
                                ProjectManager.AdvLog("File to be taken out of project not found at: " + projectPath + "/" + insideProjectPath);
                            }
                        }
                        else
                        {
                            if (Directory.Exists(projectPath + "/" + insideProjectPath))
                            {
                                // Get each folder as an array from the new file path so we can create all the nessesary folders
                                string[] splitOutsidePath = outsideProjectPath.Split("/" [0]);                                  // ["Plugins", "Android", "Example"]
                                string   curPath          = "";

                                // Minus 1 from the total iteration because the last value will be the actual folder we're moving
                                for (int i = 0; i < splitOutsidePath.Length - 1; i++)
                                {
                                    curPath += "/" + splitOutsidePath [i];

                                    if (!Directory.Exists(disabledPluginsPath + curPath))
                                    {
                                        Directory.CreateDirectory(disabledPluginsPath + curPath);
                                    }
                                }

                                // All the folders should now be created and we can move the wanted directories into them
                                MoveFile(projectPath + "/" + insideProjectPath, disabledPluginsPath + "/" + outsideProjectPath);
                                MoveFile(projectPath + "/" + insideProjectPath + ".meta", disabledPluginsPath + "/" + outsideProjectPath + ".meta");
                            }
                            else
                            {
                                ProjectManager.AdvLog("Directory to be moved out of project not found at: " + projectPath + "/" + insideProjectPath);
                            }
                        }
                    } catch (System.Exception error) {
                        ProjectManager.AdvLog("File or folder not found! " + error.Message);
                    }
                }
            }

            // Move the plugin files for the active platform
            ProjectManager.AdvLog("The activePlatformPluginFiles has " + activePlatformPluginFiles.Count + " files to move");

            if (activePlatformPluginFiles.Count > 0)
            {
                foreach (string file in activePlatformPluginFiles)
                {
                    ProjectManager.AdvLog("Yay lets move " + file);

                    // These variables are only relative to the assets folder (commented values are flipped if doAdd is false)
                    string oldFullFilePath = (doAdd ? "Disabled Plugins/" : "Assets/") + file;                     // (if doAdd) Disabled Plugins/Plugins/Android/Example.aar
                    string newFullFilePath = (doAdd ? "Assets/" : "Disabled Plugins/") + file;                     // (if doAdd) Assets/Plugins/Android/Example.aar

                    // Run GetAttributes within a try catch or if the file doesn't exist it'll throw an error (and we're calling this in the first place to see if the file exists ;_;)
                    try {
                        // Are we moving to a directory or just a file?
                        bool isDir = File.GetAttributes(projectPath + "/" + oldFullFilePath) == FileAttributes.Directory;

                        // Before we bother calculating any moving or folder creation make sure the file we're wanting to move exist
                        if (!isDir)
                        {
                            if (File.Exists(projectPath + "/" + oldFullFilePath))
                            {
                                if (!doAdd)
                                {
                                    newFullFilePath = newFullFilePath.Replace("Disabled Plugins/", "");                                      // Plugins/Android/Example.aar

                                    // Get each folder as an array from the new file path so we can create all the nessesary folders
                                    string[] splitNewPaths = newFullFilePath.Split("/" [0]);                                      // ["Plugins", "Android", "Example.aar"]
                                    string   curPath       = "";

                                    // Minus 1 from the total iteration because the last value will be the actual file
                                    for (int i = 0; i < splitNewPaths.Length - 1; i++)
                                    {
                                        curPath += "/" + splitNewPaths [i];

                                        if (!Directory.Exists(disabledPluginsPath + curPath))
                                        {
                                            Directory.CreateDirectory(disabledPluginsPath + curPath);
                                        }
                                    }

                                    // All the folders should now be created and the files can be moved
                                    MoveFile(projectPath + "/" + oldFullFilePath, disabledPluginsPath + "/" + newFullFilePath);
                                    MoveFile(projectPath + "/" + oldFullFilePath + ".meta", disabledPluginsPath + "/" + newFullFilePath + ".meta");
                                }
                                else
                                {
                                    MoveFile(projectPath + "/" + oldFullFilePath, projectPath + "/" + newFullFilePath);
                                    MoveFile(projectPath + "/" + oldFullFilePath + ".meta", projectPath + "/" + newFullFilePath + ".meta");
                                }
                            }
                            else
                            {
                                ProjectManager.AdvLog("File to be moved doesn't exist! (" + oldFullFilePath + ")");
                            }
                        }
                        else
                        {
                            if (Directory.Exists(projectPath + "/" + oldFullFilePath))
                            {
                                if (!doAdd)
                                {
                                    newFullFilePath = newFullFilePath.Replace("Disabled Plugins/", "");                                     // Plugins/Android/Example

                                    // Get each folder as an array from the new file path so we can create all the nessesary folders
                                    string[] splitNewPaths = newFullFilePath.Split("/" [0]);                                     // ["Plugins", "Android", "Example"]
                                    string   curPath       = "";

                                    // Minus 1 from the total iteration because the last value will be the actual folder
                                    for (int i = 0; i < splitNewPaths.Length - 1; i++)
                                    {
                                        curPath += "/" + splitNewPaths[i];

                                        if (!Directory.Exists(disabledPluginsPath + curPath))
                                        {
                                            Directory.CreateDirectory(disabledPluginsPath + curPath);
                                        }
                                    }

                                    // All the folders should now be created and the folder can be moved
                                    MoveFile(projectPath + "/" + oldFullFilePath, disabledPluginsPath + "/" + newFullFilePath);
                                    MoveFile(projectPath + "/" + oldFullFilePath + ".meta", disabledPluginsPath + "/" + newFullFilePath + ".meta");
                                }
                                else
                                {
                                    MoveFile(projectPath + "/" + oldFullFilePath, projectPath + "/" + newFullFilePath);
                                    MoveFile(projectPath + "/" + oldFullFilePath + ".meta", projectPath + "/" + newFullFilePath + ".meta");
                                }
                            }
                            else
                            {
                                ProjectManager.AdvLog("File to be moved doesn't exist! (" + oldFullFilePath + ")");
                            }
                        }
                    } catch (System.Exception error) {
                        ProjectManager.AdvLog("File or folder not found! " + error.Message);
                    }
                }
            }
            else
            {
                ProjectManager.AdvLog("This platform does not have any plugin files for " + value + "!");
            }
        }
        else
        {
            ProjectManager.AdvLog("Failed to create Disabled Plugins folder or it was deleted whilst moving files!");
        }

        // If this was a request to remove a plugin we now need to force re-add any files which still active plugins shared!
        if (!doAdd)
        {
            string[] ScriptingDefineSymbolNames = System.Enum.GetNames(typeof(ScriptingDefineSymbols));

            for (int i = 0; i < ScriptingDefineSymbolNames.Length; i++)
            {
                ScriptingDefineSymbols curScriptingDefineSymbol = (ScriptingDefineSymbols)i;

                if (IsScriptingDefineSymbolActive(curScriptingDefineSymbol))
                {
                    ModifyScriptingDefineSymbol(curScriptingDefineSymbol, true, userAction, true);
                }
            }
        }

        // Force reload assets otherwise it'll wait for the user to click the Unity window again
        AssetDatabase.Refresh(ImportAssetOptions.Default);
    }
コード例 #9
0
    public static bool IsScriptingDefineSymbolActive(ScriptingDefineSymbols defineSymbol)
    {
        string activeDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);

        return(activeDefineSymbols.Contains(defineSymbol.ToString()));
    }