public void Close()
 {
     if (m_DemoStore != null)
     {
         m_DemoStore.Close();
         m_DemoStore = null;
     }
 }
        /// <summary>
        /// Close the DemonstrationStore and remove it from the Agent.
        /// Has no effect if the DemonstrationStore is already closed (or wasn't opened)
        /// </summary>
        public void Close()
        {
            if (m_DemoStore != null)
            {
                RemoveDemonstrationStoreFromAgent(m_DemoStore);

                m_DemoStore.Close();
                m_DemoStore = null;
            }
        }
示例#3
0
        /// <summary>
        /// Creates demonstration store for use in recording.
        /// </summary>
        public void InitializeDemoStore(IFileSystem fileSystem = null)
        {
            m_DemoStore = new DemonstrationStore(fileSystem);
            var behaviorParams = GetComponent <BehaviorParameters>();

            demonstrationName = SanitizeName(demonstrationName, MaxNameLength);
            m_DemoStore.Initialize(
                demonstrationName,
                behaviorParams.brainParameters,
                behaviorParams.fullyQualifiedBehaviorName);
        }
 /// <summary>
 /// Creates demonstration store for use in recording.
 /// </summary>
 private void InitializeDemoStore()
 {
     m_RecordingAgent  = GetComponent <Agent>();
     m_DemoStore       = new DemonstrationStore();
     demonstrationName = SanitizeName(demonstrationName, MaxNameLength);
     m_DemoStore.Initialize(
         demonstrationName,
         GetComponent <BehaviorParameters>().brainParameters,
         GetComponent <BehaviorParameters>().behaviorName);
     Monitor.Log("Recording Demonstration of Agent: ", m_RecordingAgent.name);
 }
示例#5
0
 /// <summary>
 /// Creates demonstration store for use in recording.
 /// </summary>
 private void InitializeDemoStore()
 {
     recordingAgent    = GetComponent <Agent>();
     demoStore         = new DemonstrationStore();
     demonstrationName = SanitizeName(demonstrationName, MaxNameLength);
     demoStore.Initialize(
         demonstrationName,
         recordingAgent.brain.brainParameters,
         recordingAgent.brain.name);
     Monitor.Log("Recording Demonstration of Agent: ", recordingAgent.name);
 }
        /// <summary>
        /// Creates demonstration store for use in recording.
        /// </summary>
        public void InitializeDemoStore(IFileSystem fileSystem = null)
        {
            m_RecordingAgent = GetComponent <Agent>();
            m_DemoStore      = new DemonstrationStore(fileSystem);
            var behaviorParams = GetComponent <BehaviorParameters>();

            demonstrationName = SanitizeName(demonstrationName, MaxNameLength);
            m_DemoStore.Initialize(
                demonstrationName,
                behaviorParams.brainParameters,
                behaviorParams.fullyQualifiedBehaviorName);
            Monitor.Log("Recording Demonstration of Agent: ", m_RecordingAgent.name);
        }
 /// <summary>
 /// Initializes Demonstration store.
 /// </summary>
 private void Start()
 {
     if (Application.isEditor && record)
     {
         recordingAgent    = GetComponent <Agent>();
         demoStore         = new DemonstrationStore();
         demonstrationName = SanitizeName(demonstrationName);
         demoStore.Initialize(
             demonstrationName,
             recordingAgent.brain.brainParameters,
             recordingAgent.brain.name);
         Monitor.Log("Recording Demonstration of Agent: ", recordingAgent.name);
     }
 }
        /// <summary>
        /// Creates demonstration store for use in recording.
        /// Has no effect if the demonstration store was already created.
        /// </summary>
        internal DemonstrationStore LazyInitialize(IFileSystem fileSystem = null)
        {
            if (m_DemoStore != null)
            {
                return(m_DemoStore);
            }

            if (m_Agent == null)
            {
                m_Agent = GetComponent <Agent>();
            }

            m_FileSystem = fileSystem ?? new FileSystem();
            var behaviorParams = GetComponent <BehaviorParameters>();

            if (string.IsNullOrEmpty(demonstrationName))
            {
                demonstrationName = behaviorParams.behaviorName;
            }
            if (string.IsNullOrEmpty(demonstrationDirectory))
            {
                demonstrationDirectory = Path.Combine(Application.dataPath, "Demonstrations");
            }

            demonstrationName = SanitizeName(demonstrationName, MaxNameLength);
            var filePath = MakeDemonstrationFilePath(m_FileSystem, demonstrationDirectory, demonstrationName);
            var stream   = m_FileSystem.File.Create(filePath);

            m_DemoStore = new DemonstrationStore(stream);

            m_DemoStore.Initialize(
                demonstrationName,
                behaviorParams.brainParameters,
                behaviorParams.fullyQualifiedBehaviorName
                );

            AddDemonstrationStoreToAgent(m_DemoStore);

            return(m_DemoStore);
        }
 /// <summary>
 /// Remove additional DemonstrationStore to the Agent. It is still up to the user to Close this
 /// DemonstrationStores when recording is done.
 /// </summary>
 /// <param name="demoStore"></param>
 public void RemoveDemonstrationStoreFromAgent(DemonstrationStore demoStore)
 {
     m_Agent.DemonstrationStores.Remove(demoStore);
 }
 /// <summary>
 /// Add additional DemonstrationStore to the Agent. It is still up to the user to Close this
 /// DemonstrationStores when recording is done.
 /// </summary>
 /// <param name="demoStore"></param>
 public void AddDemonstrationStoreToAgent(DemonstrationStore demoStore)
 {
     m_Agent.DemonstrationStores.Add(demoStore);
 }