Ejemplo n.º 1
0
        internal void InitializeWithCurrentSettings()
        {
            m_AvailableSettingsAssets = FindSettingsInProject();

            m_Settings = MLAgentsSettingsManager.Settings;
            var currentSettingsPath = AssetDatabase.GetAssetPath(m_Settings);

            if (string.IsNullOrEmpty(currentSettingsPath))
            {
                if (m_AvailableSettingsAssets.Length > 0)
                {
                    m_CurrentSelectedSettingsAsset = 0;
                    m_Settings = AssetDatabase.LoadAssetAtPath <MLAgentsSettings>(m_AvailableSettingsAssets[0]);
                    MLAgentsSettingsManager.Settings = m_Settings;
                }
            }
            else
            {
                var settingsList = m_AvailableSettingsAssets.ToList();
                m_CurrentSelectedSettingsAsset = settingsList.IndexOf(currentSettingsPath);

                EditorBuildSettings.AddConfigObject(MLAgentsSettingsManager.EditorBuildSettingsConfigKey, m_Settings, true);
            }

            m_SettingsObject = new SerializedObject(m_Settings);
        }
Ejemplo n.º 2
0
 private void OnEnable()
 {
     settings          = MLAgentsSettings.GetOrCreateSettings();
     settings.Changed += OnSettingsChanged;
     TryRegainPrevTrainingProcess();
     ProcessRecoverLoop();
     UpdateBrainSaveDates();
 }
Ejemplo n.º 3
0
 public void TearDown()
 {
     if (storedConfigObject != null)
     {
         EditorBuildSettings.AddConfigObject(EditorBuildSettingsConfigKey, storedConfigObject, true);
         storedConfigObject = null;
     }
     MLAgentsSettingsManager.Destroy();
     ClearSettingsAssets();
 }
Ejemplo n.º 4
0
 public void SetUp()
 {
     if (EditorBuildSettings.TryGetConfigObject(EditorBuildSettingsConfigKey,
                                                out MLAgentsSettings settingsAsset))
     {
         if (settingsAsset != null)
         {
             storedConfigObject = settingsAsset;
             EditorBuildSettings.RemoveConfigObject(EditorBuildSettingsConfigKey);
         }
     }
     MLAgentsSettingsManager.Destroy();
     ClearSettingsAssets();
 }
Ejemplo n.º 5
0
        private static void PlayModeChange(PlayModeStateChange obj)
        {
            switch (obj)
            {
            case PlayModeStateChange.ExitingEditMode:

                var controlled = false;

                var settings = MLAgentsSettings.GetOrCreateSettings();
                if (settings.ActiveConfiguration != null && settings.ActiveConfiguration.trainInEditor)
                {
                    controlled = true;
                }

                SetAcademyBrainsControlled(controlled);
                break;
            }
        }
        public void OnPreprocessBuild(BuildReport report)
        {
            var wasDirty = IsPlayerSettingsDirty();

            m_SettingsAddedToPreloadedAssets = null;

            var preloadedAssets = PlayerSettings.GetPreloadedAssets().ToList();

            if (!preloadedAssets.Contains(MLAgentsSettingsManager.Settings))
            {
                m_SettingsAddedToPreloadedAssets = MLAgentsSettingsManager.Settings;
                preloadedAssets.Add(m_SettingsAddedToPreloadedAssets);
                PlayerSettings.SetPreloadedAssets(preloadedAssets.ToArray());
            }

            if (!wasDirty)
            {
                ClearPlayerSettingsDirtyFlag();
            }
        }
Ejemplo n.º 7
0
        public static BuildReport MakeTrainingsBuild(MLAgentsSettings settings)
        {
            var scenesToBuild = new List <string>();

            for (var i = 0; i < SceneManager.sceneCount; i++)
            {
                var scene = SceneManager.GetSceneAt(i);
                if (DetermineIsTrainingsScene(scene, true))
                {
                    Debug.Log($"Adding {scene.path} to TrainingsBuild");
                    scenesToBuild.Add(scene.path);
                }
            }

            return(BuildPipeline.BuildPlayer(
                       scenesToBuild.ToArray(),
                       settings.ActiveConfiguration.AbsolutePathToExecuteable,
                       BuildTarget.StandaloneWindows,
                       BuildOptions.None
                       ));
        }
        public void OnPostprocessBuild(BuildReport report)
        {
            if (m_SettingsAddedToPreloadedAssets == null)
            {
                return;
            }

            var wasDirty = IsPlayerSettingsDirty();

            var preloadedAssets = PlayerSettings.GetPreloadedAssets().ToList();

            if (preloadedAssets.Contains(m_SettingsAddedToPreloadedAssets))
            {
                preloadedAssets.Remove(m_SettingsAddedToPreloadedAssets);
                PlayerSettings.SetPreloadedAssets(preloadedAssets.ToArray());
            }

            m_SettingsAddedToPreloadedAssets = null;

            if (!wasDirty)
            {
                ClearPlayerSettingsDirtyFlag();
            }
        }