Import assets from store

This commit is contained in:
Sahik committed 2026-09-23 09:30:04 +08:00
1 parent a05f2e47a2
commit 376e52e323
875 files changed
+128037

No files matched your search

@@ -0,0 +1,106 @@
using UnityEngine;
namespace CharacterMovement
{
/// <summary>
/// Toggles the demo HUD and the controller's debug overlay. Demo helper; not part of the
/// character motor.
/// </summary>
[AddComponentMenu("Character Controller/Core/Demo HUD Toggle")]
public sealed class DemoHudToggle : MonoBehaviour
{
[Tooltip("Controller the rig follows. Found automatically when Auto Find Player is on.")]
[SerializeField] private PlayerController playerController;
[Tooltip("Canvas shown and hidden by the toggle key. Found by name if left empty.")]
[SerializeField] private Canvas hudCanvas;
[Tooltip("Key that shows and hides the demo HUD and the controller's debug overlay.")]
[SerializeField] private KeyCode toggleKey = KeyCode.F1;
[Tooltip("Whether the HUD starts visible.")]
[SerializeField] private bool visible = true;
private GUIStyle _hintStyle;
private void Awake()
{
ResolveReferences();
ApplyVisibility();
}
private void Update()
{
if (!InputSystemKeyCodeUtility.WasPressedThisFrame(toggleKey))
return;
visible = !visible;
ApplyVisibility();
}
private void OnGUI()
{
if (!visible)
return;
EnsureHintStyle();
const float width = 210f;
const float height = 32f;
GUI.Box(
new Rect(Screen.width - width - 16f, Screen.height - height - 16f, width, height),
"F1 - Hide HUD / debug",
_hintStyle);
}
private void ResolveReferences()
{
if (!playerController)
playerController = GetComponent<PlayerController>() ?? SceneReferenceResolver.FindComponentInSameScene<PlayerController>(this);
if (!hudCanvas)
hudCanvas = FindNamedCanvas("HUD_Canvas");
}
private Canvas FindNamedCanvas(string canvasName)
{
if (!gameObject.scene.IsValid() || !gameObject.scene.isLoaded)
return null;
GameObject[] roots = gameObject.scene.GetRootGameObjects();
for (int i = 0; i < roots.Length; i++)
{
Canvas[] canvases = roots[i].GetComponentsInChildren<Canvas>(true);
for (int j = 0; j < canvases.Length; j++)
{
if (canvases[j] && canvases[j].name == canvasName)
return canvases[j];
}
}
return null;
}
private void ApplyVisibility()
{
if (!playerController || !hudCanvas)
ResolveReferences();
if (playerController)
playerController.SetDebugOverlayVisible(visible);
if (hudCanvas)
hudCanvas.enabled = visible;
}
private void EnsureHintStyle()
{
if (_hintStyle != null)
return;
_hintStyle = new GUIStyle(GUI.skin.box)
{
alignment = TextAnchor.MiddleCenter,
fontSize = 13,
normal = { textColor = Color.white },
padding = new RectOffset(8, 8, 6, 6)
};
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a58c00ec2dc0495e9d82ee1573a5590a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 367142
packageName: "MotionCore \u2013 Physics Character Controller"
packageVersion: 1.2
assetPath: Assets/Character Controller/Core/Scripts/Demo/DemoHudToggle.cs
uploadId: 997018
@@ -0,0 +1,49 @@
using UnityEngine;
namespace CharacterMovement
{
/// <summary>
/// Ping-pongs a platform between two points. Demo helper used by the generated movement gym;
/// it is not part of the character motor.
/// </summary>
[AddComponentMenu("Character Controller/Core/Demo Moving Platform Mover")]
public sealed class DemoMovingPlatformMover : MonoBehaviour
{
[Tooltip("Offset from the starting position the platform travels to, in local space.")]
[SerializeField] private Vector3 localOffset = new Vector3(0f, 0f, 3f);
[Tooltip("Seconds for one leg of the round trip.")]
[SerializeField, Min(0.1f)] private float duration = 2.5f;
private Vector3 _startPosition;
private Rigidbody _rigidbody;
public Vector3 LocalOffset
{
get => localOffset;
set => localOffset = value;
}
public float Duration
{
get => duration;
set => duration = Mathf.Max(0.1f, value);
}
private void Awake()
{
_startPosition = transform.position;
_rigidbody = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
float phase = Mathf.PingPong(Time.time / duration, 1f);
Vector3 target = _startPosition + transform.TransformDirection(localOffset) * phase;
if (_rigidbody && _rigidbody.isKinematic)
_rigidbody.MovePosition(target);
else
transform.position = target;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b453ced1145f4db9b69f47cb743de015
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 367142
packageName: "MotionCore \u2013 Physics Character Controller"
packageVersion: 1.2
assetPath: Assets/Character Controller/Core/Scripts/Demo/DemoMovingPlatformMover.cs
uploadId: 997018