浏览代码

added run in usim window

/usim-randomization
Steven Leal 4 年前
当前提交
5ce535d7
共有 5 个文件被更改,包括 96 次插入1 次删除
  1. 3
      com.unity.perception/Editor/Unity.Perception.Editor.asmdef
  2. 83
      com.unity.perception/Editor/Randomization/RunInUSimWindow.cs
  3. 3
      com.unity.perception/Editor/Randomization/RunInUSimWindow.cs.meta
  4. 5
      com.unity.perception/Editor/Randomization/Uxml/RunInUSimWindow.uxml
  5. 3
      com.unity.perception/Editor/Randomization/Uxml/RunInUSimWindow.uxml.meta

3
com.unity.perception/Editor/Unity.Perception.Editor.asmdef


"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"Newtonsoft.Json.dll"
"Newtonsoft.Json.dll",
"ZipUtility.dll"
],
"autoReferenced": true,
"defineConstraints": [],

83
com.unity.perception/Editor/Randomization/RunInUSimWindow.cs


using System;
using System.IO;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEditor.UIElements;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
using ZipUtility;
namespace UnityEngine.Perception.Randomization.Editor
{
public class RunInUSimWindow : EditorWindow
{
SceneAsset m_MainScene;
[MenuItem("Window/Run in USim")]
public static void ShowWindow()
{
var window = GetWindow<RunInUSimWindow>();
window.titleContent = new GUIContent("Run In Unity Simulation");
window.minSize = new Vector2(250, 50);
window.Show();
}
void OnEnable()
{
var root = rootVisualElement;
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(
$"{StaticData.uxmlDir}/RunInUSimWindow.uxml").CloneTree(root);
// root.Bind(this);
}
bool CreateLinuxBuildAndZip(string buildName)
{
var pathToZip = string.Empty;
var pathToProjectBuild = Application.dataPath + "/../" + "Build/";
if (!Directory.Exists(pathToProjectBuild + buildName))
Directory.CreateDirectory(pathToProjectBuild + buildName);
pathToProjectBuild = pathToProjectBuild + buildName + "/";
// Create Linux build
var buildPlayerOptions = new BuildPlayerOptions
{
scenes = new[] { "Assets/Scenes/MainScene.unity" },
locationPathName = Path.Combine(pathToProjectBuild,buildName + ".x86_64"),
target = BuildTarget.StandaloneLinux64
};
var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
var summary = report.summary;
if (summary.result == BuildResult.Succeeded)
{
Debug.Log("Build succeeded.");
EditorUtility.DisplayProgressBar("Compress Project", "Compressing Project Build...", 0);
ulong totalSize = summary.totalSize;
// Zip the build
pathToZip = Application.dataPath + "/../" + "Build/" + buildName;
Zip.DirectoryContents(pathToZip, buildName);
EditorUtility.ClearProgressBar();
// Return path to .zip file
string[] st = Directory.GetFiles(pathToZip + "/../", buildName + ".zip");
if (st.Length != 0)
pathToZip = Path.GetFullPath(st[0]);
else
return false;
}
else
{
// m_BuildZipPathField.value = null;
return false;
}
// m_BuildZipPathField.value = pathToZip;
return true;
}
}
}

3
com.unity.perception/Editor/Randomization/RunInUSimWindow.cs.meta


fileFormatVersion: 2
guid: 21e030e241504815a3dbaad77a144aca
timeCreated: 1596820769

5
com.unity.perception/Editor/Randomization/Uxml/RunInUSimWindow.uxml


<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements">
<VisualElement>
<editor:ObjectField allow-scene-objects="false" bindingPath="m_MainScene"/>
</VisualElement>
</UXML>

3
com.unity.perception/Editor/Randomization/Uxml/RunInUSimWindow.uxml.meta


fileFormatVersion: 2
guid: 678c5d944639402c9c4d50de04c77561
timeCreated: 1596821310
正在加载...
取消
保存