Repository URL to install this package:
Version:
1.0.0 ▾
|
using System.Runtime.CompilerServices;
using Fluctio.FluctioSim.Common.Configuration;
using Fluctio.FluctioSim.Core.Components.Base;
using Fluctio.FluctioSim.EditorUtils.EditorGeneral;
using UnityEditor;
using UnityEngine;
[assembly: InternalsVisibleTo("Fluctio.FluctioSim.Core.Components")]
namespace Fluctio.FluctioSim.EditorCore.Menu
{
internal static class CreateMenu
{
private const string GameObjectPath = "GameObject/" + Config.EmojiName + "/";
private const string TopMenuPath = Config.EmojiName + "/Create/";
private const int GameObjectPriority = -9999;
private const int TopMenuPriority = 0;
private static GameObject InstantiatePrefab(params string[] pathComponents)
{
var prefab = EditorUtil.LoadAsset<GameObject>(Config.PrefabsFolderGuid, pathComponents);
var instance = Object.Instantiate(prefab, Selection.activeTransform);
instance.name = prefab.name;
Selection.activeTransform = instance.transform;
var editorComponents = instance.GetComponentsInChildren<EditorComponent>();
foreach (var editorComponent in editorComponents)
{
editorComponent.InitializePrefab();
editorComponent.OnSelfChanged();
}
return instance;
}
#region Primitives
[MenuItem(GameObjectPath + "Primitives/Ball", false, GameObjectPriority + 10)]
[MenuItem(TopMenuPath + "Primitives/Ball", false, TopMenuPriority + 10)]
private static void CreateBall() => InstantiatePrefab("Primitives", "Ball", "Ball.prefab");
[MenuItem(GameObjectPath + "Primitives/Box", false, GameObjectPriority + 15)]
[MenuItem(TopMenuPath + "Primitives/Box", false, TopMenuPriority + 15)]
private static void CreateBox() => InstantiatePrefab("Primitives", "Box", "Box.prefab");
[MenuItem(GameObjectPath + "Primitives/Cylinder", false, GameObjectPriority + 20)]
[MenuItem(TopMenuPath + "Primitives/Cylinder", false, TopMenuPriority + 20)]
private static void CreateCylinder() => InstantiatePrefab("Primitives", "Cylinder", "Cylinder.prefab");
[MenuItem(GameObjectPath + "Primitives/Capsule", false, GameObjectPriority + 25)]
[MenuItem(TopMenuPath + "Primitives/Capsule", false, TopMenuPriority + 25)]
private static void CreateCapsule() => InstantiatePrefab("Primitives", "Capsule", "Capsule.prefab");
[MenuItem(GameObjectPath + "Primitives/Mesh", false, GameObjectPriority + 30)]
[MenuItem(TopMenuPath + "Primitives/Mesh", false, TopMenuPriority + 30)]
private static void CreateMesh() => InstantiatePrefab("Primitives", "MeshPrimitive", "Mesh.prefab");
#endregion
#region Ground
[MenuItem(GameObjectPath + "Ground/Flat Floor", false, GameObjectPriority + 15)]
[MenuItem(TopMenuPath + "Ground/Flat Floor", false, TopMenuPriority + 15)]
private static void CreateFlatFloor() => InstantiatePrefab("Primitives", "Floor", "Floor.prefab");
[MenuItem(GameObjectPath + "Ground/Perlin Noise", false, GameObjectPriority + 20)]
[MenuItem(TopMenuPath + "Ground/Perlin Noise", false, TopMenuPriority + 20)]
private static void CreatePerlinNoiseGround() => InstantiatePrefab("HeightField", "PerlinNoiseGround", "PerlinNoiseGround.prefab");
[MenuItem(GameObjectPath + "Ground/Terrain Data", false, GameObjectPriority + 25)]
[MenuItem(TopMenuPath + "Ground/Terrain Data", false, TopMenuPriority + 25)]
private static void CreateTerrainDataGround() => InstantiatePrefab("HeightField", "TerrainDataGround", "TerrainDataGround.prefab");
[MenuItem(GameObjectPath + "Ground/Texture Ground", false, GameObjectPriority + 30)]
[MenuItem(TopMenuPath + "Ground/Texture Ground", false, TopMenuPriority + 30)]
private static void CreateTextureGround() => InstantiatePrefab("HeightField", "TextureGround", "TextureGround.prefab");
#endregion
#region Parts
[MenuItem(GameObjectPath + "Parts/Lever Arm", false, GameObjectPriority + 20)]
[MenuItem(TopMenuPath + "Parts/Lever Arm", false, TopMenuPriority + 20)]
private static void CreateLeverArm() => InstantiatePrefab("Parts", "LeverArm", "LeverArm.prefab");
#endregion
#region Complex
[MenuItem(GameObjectPath + "Complex/Cart Pole", false, GameObjectPriority + 25)]
[MenuItem(TopMenuPath + "Complex/Cart Pole", false, TopMenuPriority + 25)]
private static void CreateCartPole() => InstantiatePrefab("Complex", "CartPole", "CartPoleAgent.prefab");
#endregion
#region Machine Learning
[MenuItem(GameObjectPath + "Machine Learning/Agent Template", false, GameObjectPriority + 30)]
[MenuItem(TopMenuPath + "Machine Learning/Agent Template", false, TopMenuPriority + 30)]
private static void CreateAgentTemplate() => InstantiatePrefab("MachineLearning", "AgentTemplate.prefab");
[MenuItem(GameObjectPath + "Machine Learning/Time Punish", false, GameObjectPriority + 35)]
[MenuItem(TopMenuPath + "Machine Learning/Time Punish", false, TopMenuPriority + 35)]
private static void CreateTimePunish() => InstantiatePrefab("MachineLearning", "TimePunish.prefab");
[MenuItem(GameObjectPath + "Machine Learning/Punish For Distance", false, GameObjectPriority + 40)]
[MenuItem(TopMenuPath + "Machine Learning/Punish For Distance", false, TopMenuPriority + 40)]
private static void CreatePunishForDistance() => InstantiatePrefab("MachineLearning", "PunishForDistance.prefab");
[MenuItem(GameObjectPath + "Machine Learning/Reward When Close", false, GameObjectPriority + 45)]
[MenuItem(TopMenuPath + "Machine Learning/Reward When Close", false, TopMenuPriority + 45)]
private static void CreateRewardWhenClose() => InstantiatePrefab("MachineLearning", "RewardWhenClose.prefab");
[MenuItem(GameObjectPath + "Machine Learning/End Episode When Close", false, GameObjectPriority + 50)]
[MenuItem(TopMenuPath + "Machine Learning/End Episode When Close", false, TopMenuPriority + 50)]
private static void CreateEndEpisodeWhenClose() => InstantiatePrefab("MachineLearning", "EndEpisodeWhenClose.prefab");
[MenuItem(GameObjectPath + "Machine Learning/Enable Component On Big Reward", false, GameObjectPriority + 55)]
[MenuItem(TopMenuPath + "Machine Learning/Enable Component On Big Reward", false, TopMenuPriority + 55)]
private static void CreateEnableComponentOnBigReward() => InstantiatePrefab("MachineLearning", "EnableComponentOnBigReward.prefab");
#endregion
}
}