Merge pull request #53 from Unity-Technologies/open_scene_menu_option

Added an option to open the SynthDet scene to the SynthDet menu
This commit is contained in:
Mohsen K 2021-04-19 09:53:37 -07:00 коммит произвёл GitHub
Родитель a85914d111 0b81439efc
Коммит 34333508b2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 14 добавлений и 29 удалений

Просмотреть файл

@ -1,39 +1,24 @@
using SynthDet.Randomizers;
using System;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.Perception.Randomization.Randomizers.SampleRandomizers;
using UnityEngine.Perception.Randomization.Scenarios;
using BackgroundObjectPlacementRandomizer = SynthDet.Randomizers.BackgroundObjectPlacementRandomizer;
using ForegroundObjectPlacementRandomizer = SynthDet.Randomizers.ForegroundObjectPlacementRandomizer;
namespace SynthDet
{
public static class MenuItems
{
[MenuItem("SynthDet/Create Default Scenario")]
static void CreateDefaultScenario()
[MenuItem("SynthDet/Open SynthDet Scene")]
static void OpenSynthDetScene()
{
var scenarioObj = new GameObject("Scenario");
var scenario = scenarioObj.AddComponent<FixedLengthScenario>();
scenario.constants.totalIterations = 1000;
scenario.AddRandomizer(new BackgroundObjectPlacementRandomizer());
scenario.AddRandomizer(new ForegroundObjectPlacementRandomizer());
scenario.AddRandomizer(new ForegroundOccluderPlacementRandomizer());
scenario.AddRandomizer(new ForegroundOccluderScaleRandomizer());
scenario.AddRandomizer(new ForegroundScaleRandomizer());
scenario.AddRandomizer(new TextureRandomizer());
scenario.AddRandomizer(new HueOffsetRandomizer());
scenario.AddRandomizer(new RotationRandomizer());
scenario.AddRandomizer(new UnifiedRotationRandomizer());
scenario.AddRandomizer(new LightRandomizer());
scenario.AddRandomizer(new CameraRandomizer());
scenario.AddRandomizer(new ForegroundObjectMetricReporter());
scenario.AddRandomizer(new LightingInfoMetricReporter());
scenario.AddRandomizer(new CameraPostProcessingMetricReporter());
Selection.activeGameObject = scenarioObj;
}
try
{
EditorSceneManager.OpenScene("Assets/Scenes/SynthDet.unity");
}
catch (Exception e)
{
Debug.LogError("Could not open the SynthDet Scene. Make sure the file Assets/Scenes/SynthDet.unity exists and is a valid Scene.");
Debug.LogException(e);
}
}
}
}