コード例 #1
0
        // Gets existing handle for index if available.
        public static PlayerHandle GetPlayerHandle(int index)
        {
            PlayerHandle player = null;

            s_Players.TryGetValue(index, out player);
            return(player);
        }
コード例 #2
0
        public static PlayerHandle GetNewPlayerHandle()
        {
            PlayerHandle handle = new PlayerHandle(s_NextPlayerIndex);

            s_Players[handle.index] = handle;
            s_NextPlayerIndex++;
            return(handle);
        }
コード例 #3
0
 void Awake()
 {
     if (autoAssignGlobal)
     {
         handle        = PlayerHandleManager.GetNewPlayerHandle();
         handle.global = true;
         foreach (ActionMapSlot actionMapSlot in actionMaps)
         {
             ActionMapInput actionMapInput = ActionMapInput.Create(actionMapSlot.actionMap);
             actionMapInput.TryInitializeWithDevices(handle.GetApplicableDevices());
             actionMapInput.active          = actionMapSlot.active;
             actionMapInput.blockSubsequent = actionMapSlot.blockSubsequent;
             handle.maps.Add(actionMapInput);
         }
     }
 }
        void DrawPlayerHandle(PlayerHandle player)
        {
            EditorGUIUtility.labelWidth = 160;

            GUIContent playerContent = new GUIContent("Player " + player.index);

            GUILayout.BeginVertical(playerContent, Styles.playerStyle, GUILayout.Width(s_PlayerElementWidth));
            {
                GUILayout.Label("Assigned Devices", Styles.nodeLabel);
                for (int i = 0; i < s_MaxAssignedDevices; i++)
                {
                    Rect deviceRect = GUILayoutUtility.GetRect(GUIContent.none, Styles.deviceStyle, GUILayout.Width(kDeviceElementWidth));
                    if (i >= player.assignments.Count)
                    {
                        continue;
                    }
                    if (Event.current.type == EventType.Repaint)
                    {
                        devicePositionTargets[player.assignments[i].device] = deviceRect;
                    }
                }

                if (showMaps)
                {
                    GUILayout.Label("Action Map Inputs", Styles.nodeLabel);
                    for (int i = 0; i < player.maps.Count; i++)
                    {
                        DrawActionMapInput(player.maps[i]);
                    }
                }
            }
            EditorGUILayout.EndVertical();
            if (player.global)
            {
                Rect rect = GUILayoutUtility.GetLastRect();
                GUI.Label(rect, "(Global)");
            }
        }
コード例 #5
0
 internal static void RemovePlayerHandle(PlayerHandle handle)
 {
     s_Players.Remove(handle.index);
 }