Introduce a set of test tools and demo assets for an AntMan-style scaling effect: - Add AntManScaleController: handles smooth scale transitions (absolute/relative modes), pivot preservation, queued toggles and events. - Add GhostTrailEmitter and GhostTrailGhost: spawn fading ghost meshes (supports skinned mesh baking, material fallback, lifetime and pooling limit). - Add GKTInventoryScaleToggle: inventory-gated input wrapper to toggle scale with optional Ctrl bypass and auto reference resolution. - Add AntManTestSceneBootstrap and TestBootstrap prefab to quickly construct a test scene (cube, light, camera) with components configured. - Add AntManScaleTest scene and related prefab/meta files, plus .vsconfig for Unity workload. - Update SampleScene LFS pointer (scene file checksum/size). These changes provide a reusable demo and components to test scaling visuals and interactions during development.
178 lines
5.3 KiB
C#
178 lines
5.3 KiB
C#
using UnityEngine;
|
|
|
|
public class GKTInventoryScaleToggle : MonoBehaviour
|
|
{
|
|
[Header("Input")]
|
|
[SerializeField] private KeyCode toggleKey = KeyCode.L;
|
|
[SerializeField] private bool disableDirectInputOnScaleController = true;
|
|
[SerializeField] private bool allowCtrlLBypass = true;
|
|
|
|
[Header("Objeto Requerido (X)")]
|
|
[SerializeField] private string requiredInventoryObjectName = "";
|
|
[SerializeField] private bool requireObjectConfiguredInInventoryList = true;
|
|
|
|
[Header("Referencias")]
|
|
[SerializeField] private AntManScaleController scaleController;
|
|
[SerializeField] private playerComponentsManager mainPlayerComponentsManager;
|
|
[SerializeField] private inventoryManager mainInventoryManager;
|
|
|
|
[Header("Debug")]
|
|
[SerializeField] private bool showLogs = true;
|
|
|
|
private void Awake()
|
|
{
|
|
ResolveReferences();
|
|
|
|
if (scaleController != null && disableDirectInputOnScaleController)
|
|
{
|
|
scaleController.SetReadToggleInputState(false);
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(toggleKey))
|
|
{
|
|
bool bypassInventoryCheck = allowCtrlLBypass && IsControlPressed();
|
|
TryToggleScale(bypassInventoryCheck);
|
|
}
|
|
}
|
|
|
|
public void TryToggleScale(bool bypassInventoryCheck = false)
|
|
{
|
|
ResolveReferences();
|
|
|
|
if (scaleController == null)
|
|
{
|
|
if (showLogs)
|
|
{
|
|
Debug.LogWarning("[GKTInventoryScaleToggle] Falta AntManScaleController en este personaje.", this);
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (bypassInventoryCheck)
|
|
{
|
|
scaleController.RequestToggle();
|
|
|
|
if (showLogs)
|
|
{
|
|
Debug.Log("[GKTInventoryScaleToggle] Ctrl+L bypass activo. Se omite verificacion de objeto X.", this);
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (mainInventoryManager == null)
|
|
{
|
|
if (showLogs)
|
|
{
|
|
Debug.LogWarning("[GKTInventoryScaleToggle] No se encontro inventoryManager en el personaje.", this);
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(requiredInventoryObjectName))
|
|
{
|
|
if (showLogs)
|
|
{
|
|
Debug.LogWarning("[GKTInventoryScaleToggle] El objeto X aun no esta asignado. Completa Required Inventory Object Name.", this);
|
|
}
|
|
return;
|
|
}
|
|
|
|
if (requireObjectConfiguredInInventoryList && !mainInventoryManager.existInventoryInfoFromName(requiredInventoryObjectName))
|
|
{
|
|
if (showLogs)
|
|
{
|
|
Debug.LogWarning(
|
|
"[GKTInventoryScaleToggle] El objeto X no existe en el Inventory List Manager: " + requiredInventoryObjectName,
|
|
this
|
|
);
|
|
}
|
|
return;
|
|
}
|
|
|
|
int amount = mainInventoryManager.getInventoryObjectAmountByName(requiredInventoryObjectName);
|
|
bool hasObject = amount > 0;
|
|
|
|
if (!hasObject)
|
|
{
|
|
if (showLogs)
|
|
{
|
|
Debug.Log("[GKTInventoryScaleToggle] No puedes cambiar escala. Falta objeto X en inventario: " + requiredInventoryObjectName, this);
|
|
}
|
|
return;
|
|
}
|
|
|
|
scaleController.RequestToggle();
|
|
|
|
if (showLogs)
|
|
{
|
|
Debug.Log("[GKTInventoryScaleToggle] Escala alternada. Objeto X verificado: " + requiredInventoryObjectName + " x" + amount, this);
|
|
}
|
|
}
|
|
|
|
public void SetRequiredInventoryObjectName(string newObjectName)
|
|
{
|
|
requiredInventoryObjectName = newObjectName;
|
|
}
|
|
|
|
private static bool IsControlPressed()
|
|
{
|
|
return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
|
|
}
|
|
|
|
private void ResolveReferences()
|
|
{
|
|
if (scaleController == null)
|
|
{
|
|
scaleController = GetComponent<AntManScaleController>();
|
|
|
|
if (scaleController == null)
|
|
{
|
|
scaleController = GetComponentInParent<AntManScaleController>(true);
|
|
}
|
|
|
|
if (scaleController == null)
|
|
{
|
|
scaleController = GetComponentInChildren<AntManScaleController>(true);
|
|
}
|
|
}
|
|
|
|
if (mainPlayerComponentsManager == null)
|
|
{
|
|
mainPlayerComponentsManager = GetComponent<playerComponentsManager>();
|
|
|
|
if (mainPlayerComponentsManager == null)
|
|
{
|
|
mainPlayerComponentsManager = GetComponentInParent<playerComponentsManager>(true);
|
|
}
|
|
|
|
if (mainPlayerComponentsManager == null)
|
|
{
|
|
mainPlayerComponentsManager = GetComponentInChildren<playerComponentsManager>(true);
|
|
}
|
|
}
|
|
|
|
if (mainInventoryManager == null && mainPlayerComponentsManager != null)
|
|
{
|
|
mainInventoryManager = mainPlayerComponentsManager.getInventoryManager();
|
|
}
|
|
|
|
if (mainInventoryManager == null)
|
|
{
|
|
mainInventoryManager = GetComponent<inventoryManager>();
|
|
|
|
if (mainInventoryManager == null)
|
|
{
|
|
mainInventoryManager = GetComponentInParent<inventoryManager>(true);
|
|
}
|
|
|
|
if (mainInventoryManager == null)
|
|
{
|
|
mainInventoryManager = GetComponentInChildren<inventoryManager>(true);
|
|
}
|
|
}
|
|
}
|
|
}
|