I will share 3 scripts consisting of a puzzle. In the PlayerInteraction script, instead of pressing E to call the Interact() function, i want to press E to call a UI function in which I loop through my player inventory and list all of the name items containing the EldritchSymbol component. When the player click on one of the available item in the list, then it will call the Interact() function, and the player will place the item he clicked on under the current symbol transform. Also, I need anothe OnGUI function that list the name of the item in the symbol slot, and when the player clicks it, it returns back to the player inventory. I want the GUI to be center screen.
Je vais partager 3 scripts pour un puzzle dans Unity et ma propre méthode pour vérifier l'inventaire du joueur et ajouté un item dans l'inventaire. Dans ce puzzle, j'aimerais pouvoir modifier la manière que le joueur place un symbol. Dans un GUI centré dans l'écran, en vérifiant si un des 5 items comprenant la composante EldritchSymbol est dans l'inventaire, je veux que le joueur puisse lui-meme choisir l'item à placer dans le symbolSlot transform. J'aimerais aussi modifier la manière que le joeur Remove un symbol. Je veux qu'un nouveau GUI toujours centré montre le symbol actuellement placé, et qu'en cliquant sur le bouton, le joueur enlève le symbol, laissant le symbol transform vierge, puis l'item retourne dans l'inventaire du joueur. Donc, pour résumer. Changer la manière de placer et d'enlever un symbole en utilisant des GUI centré dans l'écran, pour placer un symbol il faut chercher dans l'inventaire du joueur si un item possède un symbol, puis placé cet item sur le symbol transform en pleine interaction. Pour enlever un symbole, le GUI change et montre le symbol actuellement placé sur le symbol transform, le joueur peut retirer le symbol du symbol transform et l'item retourne dans l'inventaire du joueur. 
Script 1:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LovecraftianPuzzle : MonoBehaviour
{
public enum EldritchSymbols { Nyarlathotep, Azathoth, Cthulhu, ShubNiggurath, YogSothoth }
public Transform[] symbolSlots;
public GameObject[] eldritchSymbolPrefabs;
public GameObject portal;
public Animator portalAnimator;
public AudioSource gatewayAudio;
public AudioClip placeSymbolSound;
private GameObject player;
private AudioSource playerAudioSource;




private void Start()
{
    player = GameObject.Find("Player");
    playerAudioSource = player.GetComponent<AudioSource>();
}
private List<EldritchSymbols> correctOrder = new List<EldritchSymbols>()
{
    EldritchSymbols.Nyarlathotep,
    EldritchSymbols.Azathoth,
    EldritchSymbols.Cthulhu,
    EldritchSymbols.ShubNiggurath,
    EldritchSymbols.YogSothoth
};

private List<EldritchSymbols> currentOrder = new List<EldritchSymbols>();

private Dictionary<EldritchSymbols, int> symbolToSlotIndex = new Dictionary<EldritchSymbols, int>()
{
{ EldritchSymbols.Nyarlathotep, 0 },
{ EldritchSymbols.Cthulhu, 2 },
{ EldritchSymbols.Azathoth, 1 },
{ EldritchSymbols.ShubNiggurath, 3 },
{ EldritchSymbols.YogSothoth, 4 }
};
public void PlaceSymbol(EldritchSymbols symbol)
{
int slotIndex = symbolToSlotIndex[symbol];
if (symbolSlots[slotIndex].childCount == 0)
{
GameObject symbolObject = Instantiate(
eldritchSymbolPrefabs[(int)symbol],
symbolSlots[slotIndex].position,
Quaternion.Euler(0, 24, -90), // Rotate 90 degrees around the Z axis
symbolSlots[slotIndex]);
if (!currentOrder.Contains(symbol)) // Check if the symbol is already in the list
{
currentOrder.Add(symbol); // Add it only if it's not present
}
playerAudioSource.PlayOneShot(placeSymbolSound);
}




    CheckPuzzleSolved();
}

private void CheckPuzzleSolved()
{
    if (currentOrder.Count == correctOrder.Count)
    {
        bool isSolved = true;

        for (int i = 0; i < correctOrder.Count; i++)
        {
            if (currentOrder[i] != correctOrder[i])
            {
                isSolved = false;
                break;
            }
        }

        if (isSolved)
        {
            StartCoroutine(GatewayAnimation());
        }
    }
}
public IEnumerator GatewayAnimation()
{
    portalAnimator.SetBool("OpenGateway", true);
    MeshCollider gatewayMeshFilter = portalAnimator.gameObject.GetComponent<MeshCollider>();
    gatewayAudio.Play();
    gatewayMeshFilter.enabled = false;
    yield return new WaitForSeconds(1f);
    portalAnimator.SetBool("OpenGateway", false);
}

public void ResetPuzzle()
{
    currentOrder.Clear();

    foreach (Transform slot in symbolSlots)
    {
        if (slot.childCount > 0)
        {
            Destroy(slot.GetChild(0).gameObject);
        }
    }
}

public void RemoveSymbol(EldritchSymbols symbol)
{
    // Find the index of the symbol in the currentOrder list
    int index = currentOrder.FindIndex(s => s == symbol);

    // Check that the index is valid
    if (index >= 0 && index < currentOrder.Count)
    {
        // Find the corresponding symbol in the symbolSlots array
        for (int i = 0; i < symbolSlots.Length; i++)
        {
            if (symbolSlots[i].childCount > 0)
            {
                GameObject symbolObject = symbolSlots[i].GetChild(0).gameObject;
                EldritchSymbols symbolInSlot = symbolObject.GetComponent<EldritchSymbol>().symbolType;

                if (symbolInSlot == symbol)
                {
                    // Remove the symbol from currentOrder and destroy the symbol object
                    currentOrder.RemoveAt(index);
                    playerAudioSource.PlayOneShot(placeSymbolSound);
                    Destroy(symbolObject);
                    break;
                }
            }
        }
    }
}
}

Script 2:
using UnityEngine;

public class EldritchSymbol : MonoBehaviour
{
public LovecraftianPuzzle.EldritchSymbols symbolType;
}

Script 3:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerInteraction : MonoBehaviour
{
public float interactionDistance = 2f;
public LayerMask interactionMask;
private GameObject currentInteractable;
private GameObject lastPlacedSymbol;
void Update()
{
if (Input.GetKeyDown(KeyCode.E))
{
Interact();
}
}




void FixedUpdate()
{
    CheckForInteractions();
}

void CheckForInteractions()
{
    RaycastHit hitInfo;
    if (Physics.Raycast(transform.position, transform.forward, out hitInfo, interactionDistance, interactionMask))
    {
        if (hitInfo.transform.gameObject != currentInteractable)
        {
            currentInteractable = hitInfo.transform.gameObject;
            Debug.Log("New Interactable: " + currentInteractable.name);

            // You can add visual feedback or highlighting for the interactable object here.
        }
    }
    /*else
    {
        if (currentInteractable != null)
        {
            currentInteractable = null;
            Debug.Log("No interactable object in range.");

            // You can remove visual feedback or highlighting for the interactable object here.
        }
    }*/
}

void Interact()
{
    if (currentInteractable != null)
    {
        EldritchSymbol symbol = currentInteractable.GetComponent<EldritchSymbol>();
        if (symbol != null)
        {
            LovecraftianPuzzle puzzle = FindObjectOfType<LovecraftianPuzzle>();
            if (puzzle != null)
            {
                if (lastPlacedSymbol == currentInteractable)
                {
                    puzzle.RemoveSymbol(symbol.symbolType);
                    lastPlacedSymbol = null; // Reset the last placed symbol
                }
                else
                {
                    puzzle.PlaceSymbol(symbol.symbolType);
                    lastPlacedSymbol = currentInteractable; // Store the placed symbol
                }
            }
        }
    }
}
}

Here's an exemple on how I loop for Item name in my Inventory:
for (int t = 0; t < InvManager.Items; t++) //Starting a loop in the slots of the inventory:
{
if (InvManager.Slots[t].IsTaken == true) //Checking if there's an item in this slot.
{
Item ItemScript = InvManager.Slots[t].Item.GetComponent(); //Getting the item script from the items inside the bag.
if (ItemScript.Name == "The Shadow People"){//Do stuff}

Here's an exemple on how I add an item in my inventory:
if (InvManager.PickupType == InventoryManager.PickupTypes.Keyboard) //Check if the player is using the keyboard to pick up items.
			{
				if (Input.GetKey(InvManager.ActionKey)) //Checking if the player pressed the key used to pick up items.
				{
					//if(other == InvManager.Player.GetComponent<Collider>()) 
					//{
					if (ItemType == 0)
					{
						PlayerPrefs.SetString(id, "true");
						_itemCollected = true;
						InvManager.AddItem(MyTransform); //Add this item to the bag

					}
				}
			}

Additionnal Note : Items having the EldritchSymbol are books. They are having different names and each of them possess one of the symbol.
"The Unknown and The Deep Void" (Yog Sothoth)
"Mark Of The Old Gods" (Azathoth)
"The House Of R'lyeh" (Cthulhu)
"The Shadow People" (Shub Niggurath)
"Invocations of The Cosmic Horror" (Nyalarthotep)

Même si le joueur peut placer n'importe quel livre n'importe où, chaque livre doit être placé sur le bon symboleTransformation ET dans le bon ordre. 
Enfin, c'est ce que j'aimerais accomplir.