'using UnityEngine;

public class InventorySlot : MonoBehaviour
{
    [Header("References")]
    public Transform modelDisplayPoint;  // For preview in inventory UI
    public Transform throwOrigin;        // Where to throw object from
    public Transform holdPoint;          // In front of camera for real object

    [Header("Visual Settings")]
    public Vector3 heldScale = new Vector3(0.5f, 0.5f, 0.5f);
    public Vector3 heldRotation = new Vector3(10f, 180f, 0f);
    public Vector3 activeScale = new Vector3(1.1f, 1.1f, 1.1f);
    public Vector3 normalScale = Vector3.one;

    private GameObject storedItem;
    private GameObject previewInstance;
    private string originalObjectName;
    private Vector3 originalScale;

    public void SetActiveVisual(bool isActive)
    {
        transform.localScale = isActive ? activeScale : normalScale;

        if (storedItem != null)
        {
            storedItem.SetActive(isActive);
        }
    }

    public bool HasItem()
    {
        return storedItem != null;
    }

    public void StoreItem(GameObject item)
    {
        storedItem = item;
        originalObjectName = item.name;
        originalScale = item.transform.localScale;

        // Rename object to slot
        item.name = gameObject.name;

        // Smooth scale + rotate to hold
        item.transform.localScale = heldScale;
        item.transform.localRotation = Quaternion.Euler(heldRotation);

        // Move to front of camera (hold point)
        if (holdPoint != null)
        {
            item.transform.SetParent(holdPoint);
            item.transform.localPosition = new Vector3(0.3f, -0.2f, 0.6f); // tweak as needed
        }

        // Make kinematic if has Rigidbody
        Rigidbody rb = item.GetComponent<Rigidbody>();
        if (rb != null)
        {
            rb.isKinematic = true;
            rb.useGravity = false;
        }

        storedItem.SetActive(false);
        CreatePreview(item);

        gameObject.name = "Slot_" + originalObjectName;
    }

    void CreatePreview(GameObject item)
    {
        if (previewInstance != null)
            Destroy(previewInstance);

        previewInstance = Instantiate(item, modelDisplayPoint.position, Quaternion.identity, modelDisplayPoint);
        previewInstance.transform.localScale = Vector3.one * 0.3f;
        previewInstance.transform.rotation = Quaternion.Euler(heldRotation);

        DestroyImmediate(previewInstance.GetComponent<Rigidbody>());
        DestroyImmediate(previewInstance.GetComponent<Collider>());
    }

    public void ThrowItem()
    {
        if (storedItem == null) return;

        // Restore original name & scale
        storedItem.name = originalObjectName;
        storedItem.transform.localScale = originalScale;

        // Unparent and show
        storedItem.SetActive(true);
        storedItem.transform.SetParent(null);
        storedItem.transform.position = throwOrigin != null ? throwOrigin.position : modelDisplayPoint.position;
        storedItem.transform.rotation = Quaternion.identity;

        Rigidbody rb = storedItem.GetComponent<Rigidbody>();
        if (rb == null)
            rb = storedItem.AddComponent<Rigidbody>();

        rb.isKinematic = false;
        rb.useGravity = true;
        rb.linearVelocity = Vector3.zero;
        rb.angularVelocity = Vector3.zero;
        rb.AddForce(throwOrigin.forward * 7f, ForceMode.Impulse);

        Destroy(previewInstance);
        previewInstance = null;
        storedItem = null;

        gameObject.name = "Empty_Slot";
    }

    public GameObject GetStoredItem()
    {
        return storedItem;
    }
}
' now i need instant of change scale on active inventory change color this color i give in public