Exemplo n.º 1
0
    public void PlaceBindings()
    {
        // Clear the existing binding images
        ClearAllBindings();

        // Get the latest bindings from the binding manager
        var newestBindings = m_bindingManager.KeyBindings;

        // Create portraits for all of the bindings
        foreach (KeyValuePair <KeyCode, Call_Individual> bindPair in newestBindings)
        {
            // Determine the index for the placement in the UI
            int uiKeyIndex = m_keyboardLayout.GetIndexFromKeyCode(bindPair.Key);

            // Toggle the main keyboard letter so that it appears if the slot is empty but hides if a caller is in it
            m_keyboardLetters[uiKeyIndex].gameObject.SetActive(bindPair.Value == null);

            // If this binding isn't set, turn the key back on and then move on
            if (bindPair.Value == null)
            {
                continue;
            }

            // Otherwise, determine which which caller the portrait should represent
            Call_Individual caller = bindPair.Value;

            // Now, spawn a new portrait on the right UI key and set it up with the caller object
            GameObject         portraitObj = Instantiate(m_callerUIPrefab, m_keyPortraitParents[uiKeyIndex]);
            Call_Individual_UI uiComp      = portraitObj.GetComponent <Call_Individual_UI>();
            uiComp.InitWithData(caller);
        }
    }
    public void PlacePortraits(List <Call_Individual> _callers)
    {
        // Start by clearing all of the existing portraits
        ClearAllPortraits();

        // Reset the list of UI objects
        m_uiObjs = new List <Call_Individual_UI>();

        // Loop through the portrait holders and spawn new portraits based on the given callers
        for (int i = 0; i < _callers.Count; i++)
        {
            // Spawn a new portrait into the slot
            GameObject newPortrait = Instantiate(m_portraitPrefab, m_portraitHolders[i]);

            // Grab the UI script and get it setup then store the ref to it
            Call_Individual_UI uiComp = newPortrait.GetComponent <Call_Individual_UI>();
            uiComp.InitWithData(_callers[i]);
            m_uiObjs.Add(uiComp);
        }
    }