Skip to content

Commit

Permalink
update: fix parenting and script names
Browse files Browse the repository at this point in the history
also made egoTransform field public in AutowareSimulation.cs
Signed-off-by: Alptuğ Cırıt <[email protected]>
  • Loading branch information
mozhoku committed Mar 11, 2024
1 parent 5f9a084 commit 528b665
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 100 deletions.
78 changes: 22 additions & 56 deletions Assets/AWSIM/Scenes/Main/AutowareSimulation.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 1520.0924, g: 1884.674, b: 2491.8425, a: 1}
m_IndirectSpecularColor: {r: 1519.6069, g: 1883.9946, b: 2490.9849, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -506,7 +506,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a859dd040b8ec0fdb9def835830af1d5, type: 3}
m_Name:
m_EditorClassIdentifier:
egoTransform: {fileID: 7808269042169720464}
guiCanvas: {fileID: 412951385}
--- !u!114 &412951381
MonoBehaviour:
Expand Down Expand Up @@ -619,60 +618,14 @@ RectTransform:
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 1871503624}
m_Father: {fileID: 439585505}
m_RootOrder: 1
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &439585503
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 439585505}
- component: {fileID: 439585504}
m_Layer: 0
m_Name: UI Elements
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &439585504
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 439585503}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e57d8ec76c1a4b541a265df86dae64d9, type: 3}
m_Name:
m_EditorClassIdentifier:
egoTransform: {fileID: 7808269042169720464}
--- !u!4 &439585505
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 439585503}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1511771841}
- {fileID: 412951386}
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &543989979
GameObject:
m_ObjectHideFlags: 0
Expand All @@ -684,6 +637,7 @@ GameObject:
- component: {fileID: 543989980}
- component: {fileID: 543989981}
- component: {fileID: 543989982}
- component: {fileID: 543989983}
m_Layer: 0
m_Name: AutowareSimulation
m_TagString: Untagged
Expand Down Expand Up @@ -741,6 +695,18 @@ MonoBehaviour:
commandLineConfigParam: --json_path
useJsonConfig: 0
jsonPath:
--- !u!114 &543989983
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 543989979}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e57d8ec76c1a4b541a265df86dae64d9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &553355659 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 9027057600446549292, guid: 58d73df60b244d146bdf5f5896f78355, type: 3}
Expand Down Expand Up @@ -3057,7 +3023,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &890457390 stripped
MonoBehaviour:
Expand Down Expand Up @@ -3326,7 +3292,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1153401687
GameObject:
Expand Down Expand Up @@ -4258,8 +4224,8 @@ RectTransform:
- {fileID: 797679384}
- {fileID: 556633328}
- {fileID: 1381324631}
m_Father: {fileID: 439585505}
m_RootOrder: 0
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
Expand Down Expand Up @@ -4657,8 +4623,8 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 439585504}
m_TargetAssemblyTypeName: UserShortcuts, Assembly-CSharp
- m_Target: {fileID: 543989983}
m_TargetAssemblyTypeName: AWSIM.HotkeyHandler, Assembly-CSharp
m_MethodName: ResetEgoToSpawnPoint
m_Mode: 1
m_Arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace AWSIM
public class AutowareSimulation : MonoBehaviour
{
[SerializeField] TrafficManager trafficManager;
[SerializeField] Transform egoTransform;
[SerializeField] public Transform egoTransform;
[SerializeField] TimeSourceSelector timeSourceSelector;

[Header("Player Config")]
Expand Down
49 changes: 49 additions & 0 deletions Assets/AWSIM/Scripts/UI/HotkeyHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using UnityEngine;


//This script will be improved in the future. Temporarily it will be a bit dirty.
namespace AWSIM
{
public class HotkeyHandler : MonoBehaviour
{
private AutowareSimulation _simulation;
private Transform _egoTransform;
private Rigidbody _egoRigidbody;
private Vector3 _initialEgoPosition;
private Quaternion _initialEgoRotation;


private void Start()
{
_egoTransform = gameObject.GetComponent<AutowareSimulation>().egoTransform;
// Store the initial position and rotation of the ego.
_initialEgoPosition = _egoTransform.position;
_initialEgoRotation = _egoTransform.rotation;
// Get the rigidbody of the ego
_egoRigidbody = _egoTransform.GetComponent<Rigidbody>();
}

void Update()
{
// If the escape key is pressed, toggle the GUI panel.
if (Input.GetKeyDown(KeyCode.R))
{
ResetEgoToSpawnPoint();
}
}

// If the ego transform reference is present, reset the ego to the initial position and rotation.
public void ResetEgoToSpawnPoint()
{
if (_egoTransform == null)
{
Debug.LogWarning("Ego transform reference is missing. No ego to reset here!");
}
else
{
_egoTransform.SetPositionAndRotation(_initialEgoPosition, _initialEgoRotation);
_egoRigidbody.Sleep();
}
}
}
}
43 changes: 0 additions & 43 deletions Assets/AWSIM/Scripts/UI/UserShortcuts.cs

This file was deleted.

0 comments on commit 528b665

Please sign in to comment.