forked from tier4/AWSIM
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alptuğ Cırıt <[email protected]>
- Loading branch information
Showing
48 changed files
with
5,774 additions
and
2,310 deletions.
There are no files selected for viewing
Empty file.
6,079 changes: 3,800 additions & 2,279 deletions
6,079
Assets/AWSIM/Scenes/Main/AutowareSimulation.unity
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
Assets/AWSIM/Scripts/UI/Toggle/UITrafficControlPlayToggle.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace AWSIM.Scripts.UI.Toggle | ||
{ | ||
public class UITrafficControlPlayToggle : MonoBehaviour | ||
{ | ||
[SerializeField] public Sprite sprite1; | ||
[SerializeField] public Sprite sprite2; | ||
|
||
private TrafficControlManager trafficControlManager; | ||
private Image image; | ||
|
||
private void Start() | ||
{ | ||
image = GetComponent<Image>(); | ||
trafficControlManager = FindObjectOfType<TrafficControlManager>(); | ||
trafficControlManager.trafficPlayToggleEvent.AddListener(OnStatusChangeUpdateImage); | ||
} | ||
|
||
private void OnStatusChangeUpdateImage(bool isToggled) | ||
{ | ||
Debug.Log("OnStatusChangeUpdateImage called. isToggled: " + isToggled); | ||
|
||
image.sprite = isToggled ? sprite1 : sprite2; | ||
} | ||
|
||
private void OnDestroy() | ||
{ | ||
trafficControlManager.trafficPlayToggleEvent.RemoveListener(OnStatusChangeUpdateImage); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/AWSIM/Scripts/UI/Toggle/UITrafficControlPlayToggle.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
Assets/AWSIM/Scripts/UI/Toggle/UITrafficControlVisibilityToggle.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace AWSIM.Scripts.UI.Toggle | ||
{ | ||
public class UITrafficControlVisibilityToggle : MonoBehaviour | ||
{ | ||
[SerializeField] private Sprite sprite1; | ||
[SerializeField] private Sprite sprite2; | ||
|
||
private TrafficControlManager trafficControlManager; | ||
private Image image; | ||
|
||
private void Start() | ||
{ | ||
image = GetComponent<Image>(); | ||
trafficControlManager = FindObjectOfType<TrafficControlManager>(); | ||
trafficControlManager.trafficVisibilityToggleEvent.AddListener(OnStatusChangeUpdateImage); | ||
} | ||
|
||
private void OnStatusChangeUpdateImage(bool isToggled) | ||
{ | ||
Debug.Log("OnStatusChangeUpdateImage called. isToggled: " + isToggled); | ||
|
||
image.sprite = isToggled ? sprite1 : sprite2; | ||
} | ||
|
||
private void OnDestroy() | ||
{ | ||
trafficControlManager.trafficVisibilityToggleEvent.RemoveListener(OnStatusChangeUpdateImage); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/AWSIM/Scripts/UI/Toggle/UITrafficControlVisibilityToggle.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.Collections; | ||
using UnityEngine; | ||
|
||
namespace AWSIM.Scripts.UI | ||
{ | ||
// Functions used by the UI elements | ||
public static class UIFunctions | ||
{ | ||
// Lerp UI objects position | ||
public static IEnumerator LerpUIRectPosition(RectTransform uiRect, Vector2 targetPosition, float lerpValue, bool willDisableAtEnd) | ||
{ | ||
float elapsedTime = 0f; | ||
Vector2 currentPosition = uiRect.anchoredPosition; | ||
|
||
while (elapsedTime < 1f) | ||
{ | ||
elapsedTime += Time.deltaTime * lerpValue; | ||
uiRect.anchoredPosition = Vector2.Lerp(currentPosition, targetPosition, elapsedTime); | ||
yield return null; | ||
} | ||
|
||
// Ensure the UI element is exactly at the target position | ||
uiRect.anchoredPosition = targetPosition; | ||
|
||
// Disable at end if wanted | ||
if (willDisableAtEnd) | ||
{ | ||
uiRect.gameObject.SetActive(false); | ||
} | ||
} | ||
|
||
// Lerp UI objects height | ||
public static IEnumerator LerpUIRectHeight(RectTransform uiRect, float targetHeight, float lerpValue, bool willDisableAtEnd) | ||
{ | ||
float elapsedTime = 0f; | ||
float currentHeight = uiRect.sizeDelta.y; | ||
|
||
while (elapsedTime < 1f) | ||
{ | ||
elapsedTime += Time.deltaTime * lerpValue; | ||
float lerpedHeight = Mathf.Lerp(currentHeight, targetHeight, elapsedTime); | ||
uiRect.sizeDelta = new Vector2(uiRect.sizeDelta.x, lerpedHeight); | ||
yield return null; | ||
} | ||
|
||
// Ensure the UI element has the target height | ||
uiRect.sizeDelta = new Vector2(uiRect.sizeDelta.x, targetHeight); | ||
|
||
// Disable at end if wanted | ||
if (willDisableAtEnd) | ||
{ | ||
uiRect.gameObject.SetActive(false); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.