浏览代码

User can choose their base directory

/main
Steve Borkman 3 年前
当前提交
ebd0315d
共有 2 个文件被更改,包括 29 次插入1 次删除
  1. 12
      com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs
  2. 18
      com.unity.perception/Runtime/GroundTruth/SimulationState.cs

12
com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs


using System;
using System.Collections.Generic;
using System.IO;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.Perception.GroundTruth;

GUILayout.BeginVertical("TextArea");
EditorGUILayout.HelpBox(dir, MessageType.None);
GUILayout.BeginHorizontal();
if (GUILayout.Button("Choose Base Folder"))
{
var path = EditorUtility.OpenFolderPanel("Choose Base Folder", "", "");
if (path.Length != 0)
{
Debug.Log($"Chose path: {path}");
PlayerPrefs.SetString(SimulationState.userBaseDirectoryKey, path);
PlayerPrefs.SetString(SimulationState.latestOutputDirectoryKey, path);
perceptionCamera.baseDirectory = path;
}
}
if (GUILayout.Button("Show Folder"))
{
EditorUtility.RevealInFinder(dir);

18
com.unity.perception/Runtime/GroundTruth/SimulationState.cs


float m_LastTimeScale;
readonly string m_OutputDirectoryName;
string m_OutputDirectoryPath;
public const string userBaseDirectoryKey = "userBaseDirectory";
public const string latestOutputDirectoryKey = "latestOutputDirectory";
public bool IsRunning { get; private set; }

public SimulationState(string outputDirectory)
{
m_OutputDirectoryName = outputDirectory;
PlayerPrefs.SetString(latestOutputDirectoryKey, Manager.Instance.GetDirectoryFor());
var basePath = PlayerPrefs.GetString(userBaseDirectoryKey, string.Empty);
if (basePath != string.Empty)
{
if (Directory.Exists(basePath))
{
Configuration.localPersistentDataPath = basePath;
}
else
{
Debug.LogWarning($"Passed in directory to store simulation artifacts: {basePath}, does not exist. Using default directory {Configuration.localPersistentDataPath} instead.");
basePath = Configuration.localPersistentDataPath;
}
}
PlayerPrefs.SetString(latestOutputDirectoryKey, Manager.Instance.GetDirectoryFor("", basePath));
IsRunning = true;
}

正在加载...
取消
保存