Добавлен функционал выбора кол-ва игроков
This commit is contained in:
parent
d4768d590b
commit
8b71a920ae
@ -21,6 +21,16 @@ public class Starter : MonoBehaviour
|
|||||||
_dontMovePlayer1.DeactivateInput();
|
_dontMovePlayer1.DeactivateInput();
|
||||||
_dontMovePlayer2.DeactivateInput();
|
_dontMovePlayer2.DeactivateInput();
|
||||||
|
|
||||||
|
if (StaticDataMap.NumPlayer == 1)
|
||||||
|
{
|
||||||
|
_dontMovePlayer1.DeactivateInput();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_dontMovePlayer1.DeactivateInput();
|
||||||
|
_dontMovePlayer2.DeactivateInput();
|
||||||
|
}
|
||||||
|
|
||||||
_borders.enabled = true;
|
_borders.enabled = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -38,8 +48,18 @@ public class Starter : MonoBehaviour
|
|||||||
if (_timer != null)
|
if (_timer != null)
|
||||||
{
|
{
|
||||||
Destroy(_timer.gameObject);
|
Destroy(_timer.gameObject);
|
||||||
_dontMovePlayer1.ActivateInput();
|
|
||||||
_dontMovePlayer2.ActivateInput();
|
if (StaticDataMap.NumPlayer == 1)
|
||||||
|
{
|
||||||
|
_dontMovePlayer1.ActivateInput();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_dontMovePlayer1.ActivateInput();
|
||||||
|
_dontMovePlayer2.ActivateInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_borders.enabled = false;
|
_borders.enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 0cd8157dcfbd7ea4686914e88dd0c837
|
guid: 6c1f37e4a62bfc241adeb23930f10139
|
||||||
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
Binary file not shown.
Binary file not shown.
@ -1,11 +1,28 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
public class CheckNumPlayerScript : MonoBehaviour
|
public class CheckNumPlayerScript : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private SetActiveScript _setActiveScript;
|
[SerializeField] private SetActiveScript _setActiveFirstPlayer;
|
||||||
|
[SerializeField] private SetActiveScript _setActiveSecondPlayer;
|
||||||
|
|
||||||
//private void Awake()
|
[SerializeField] Camera _CameraFirstPlayer;
|
||||||
//{
|
[SerializeField] Camera _CameraSecondPlayer;
|
||||||
// _setActiveScript.SetNoActiveSelected();
|
|
||||||
//}
|
private void Start()
|
||||||
|
{
|
||||||
|
if (StaticDataMap.NumPlayer == 1)
|
||||||
|
{
|
||||||
|
_setActiveFirstPlayer.SetActiveSelected();
|
||||||
|
_CameraFirstPlayer.rect = new Rect(0f, 0f, 1f, 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_setActiveFirstPlayer.SetActiveSelected();
|
||||||
|
_setActiveSecondPlayer.SetActiveSelected();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,12 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class SetActiveScript : MonoBehaviour
|
public class SetActiveScript : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private List<GameObject> _ActiveGameObject;
|
public List<GameObject> ActiveGameObject;
|
||||||
[SerializeField] private List<GameObject> _NoActiveGameObject;
|
public List<GameObject> NoActiveGameObject;
|
||||||
|
|
||||||
public void SetActiveSelected()
|
public void SetActiveSelected()
|
||||||
{
|
{
|
||||||
foreach (GameObject item in _ActiveGameObject)
|
foreach (GameObject item in ActiveGameObject)
|
||||||
{
|
{
|
||||||
item.SetActive(true);
|
item.SetActive(true);
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@ public class SetActiveScript : MonoBehaviour
|
|||||||
|
|
||||||
public void SetNoActiveSelected()
|
public void SetNoActiveSelected()
|
||||||
{
|
{
|
||||||
foreach (GameObject item in _NoActiveGameObject)
|
foreach (GameObject item in NoActiveGameObject)
|
||||||
{
|
{
|
||||||
item.SetActive(false);
|
item.SetActive(false);
|
||||||
}
|
}
|
||||||
|
559
Assets/RealisticCarControllerV3/Resources/test_rcc.cs
Normal file
559
Assets/RealisticCarControllerV3/Resources/test_rcc.cs
Normal file
@ -0,0 +1,559 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
||||||
|
// version 1.7.0
|
||||||
|
// from Assets/RealisticCarControllerV3/Resources/test_rcc.inputactions
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
using UnityEngine.InputSystem.Utilities;
|
||||||
|
|
||||||
|
public partial class @Test_rcc: IInputActionCollection2, IDisposable
|
||||||
|
{
|
||||||
|
public InputActionAsset asset { get; }
|
||||||
|
public @Test_rcc()
|
||||||
|
{
|
||||||
|
asset = InputActionAsset.FromJson(@"{
|
||||||
|
""name"": ""test_rcc"",
|
||||||
|
""maps"": [
|
||||||
|
{
|
||||||
|
""name"": ""Vehicle"",
|
||||||
|
""id"": ""e778ecfe-5b91-44bf-b7fa-c516e546c833"",
|
||||||
|
""actions"": [
|
||||||
|
{
|
||||||
|
""name"": ""Throttle"",
|
||||||
|
""type"": ""Value"",
|
||||||
|
""id"": ""719fa1bf-f48b-46d9-8254-7e2c58542997"",
|
||||||
|
""expectedControlType"": ""Axis"",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""initialStateCheck"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Steering"",
|
||||||
|
""type"": ""Value"",
|
||||||
|
""id"": ""4a484e20-6a82-42e5-8b5b-017674845d1e"",
|
||||||
|
""expectedControlType"": ""Vector2"",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""initialStateCheck"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Handbrake"",
|
||||||
|
""type"": ""Button"",
|
||||||
|
""id"": ""0b99c730-2ecb-4648-96de-0452e1221e51"",
|
||||||
|
""expectedControlType"": ""Button"",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""initialStateCheck"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""NOS"",
|
||||||
|
""type"": ""Value"",
|
||||||
|
""id"": ""f83566e3-ece7-4a2b-8770-bf682285a87f"",
|
||||||
|
""expectedControlType"": ""Axis"",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": ""Press"",
|
||||||
|
""initialStateCheck"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Menu"",
|
||||||
|
""type"": ""Button"",
|
||||||
|
""id"": ""d45e86ca-ce8d-44c8-bb37-d4a6549eb962"",
|
||||||
|
""expectedControlType"": ""Button"",
|
||||||
|
""processors"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""initialStateCheck"": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
""bindings"": [
|
||||||
|
{
|
||||||
|
""name"": ""Gamepad"",
|
||||||
|
""id"": ""0ce9d8c6-c73a-4f0f-b589-06157ec578e9"",
|
||||||
|
""path"": ""1DAxis"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Throttle"",
|
||||||
|
""isComposite"": true,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""negative"",
|
||||||
|
""id"": ""ab03bf58-d6f1-4e38-9389-25f8ff5d122c"",
|
||||||
|
""path"": ""<Gamepad>/leftTrigger"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Gamepad"",
|
||||||
|
""action"": ""Throttle"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""positive"",
|
||||||
|
""id"": ""d6d6b9ef-4d36-46e0-b3e1-355eb133d84b"",
|
||||||
|
""path"": ""<Gamepad>/rightTrigger"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Gamepad"",
|
||||||
|
""action"": ""Throttle"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Keyboard"",
|
||||||
|
""id"": ""9194693b-7c4f-425d-8c96-f54db1eca8b7"",
|
||||||
|
""path"": ""1DAxis"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Throttle"",
|
||||||
|
""isComposite"": true,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""negative"",
|
||||||
|
""id"": ""6c933367-c71d-44dd-abf8-0f71205c4259"",
|
||||||
|
""path"": ""<Keyboard>/s"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Keyboard"",
|
||||||
|
""action"": ""Throttle"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""positive"",
|
||||||
|
""id"": ""14950296-ddfa-45da-a8a1-841dc23e7bed"",
|
||||||
|
""path"": ""<Keyboard>/w"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Keyboard"",
|
||||||
|
""action"": ""Throttle"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Gamepad"",
|
||||||
|
""id"": ""890eb4a4-7dfa-423d-b9dd-a5ba330c7482"",
|
||||||
|
""path"": ""2DVector"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Steering"",
|
||||||
|
""isComposite"": true,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Left"",
|
||||||
|
""id"": ""17e7d668-3008-4739-a331-639d6356d3d1"",
|
||||||
|
""path"": ""<Gamepad>/leftStick/left"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Gamepad"",
|
||||||
|
""action"": ""Steering"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Right"",
|
||||||
|
""id"": ""068e7b91-f796-49ca-a954-d10a2b79065f"",
|
||||||
|
""path"": ""<Gamepad>/leftStick/right"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Gamepad"",
|
||||||
|
""action"": ""Steering"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Keyboard"",
|
||||||
|
""id"": ""2b119774-42e0-4af7-a6d0-f80ab7a1d792"",
|
||||||
|
""path"": ""2DVector"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Steering"",
|
||||||
|
""isComposite"": true,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""left"",
|
||||||
|
""id"": ""c4725932-bf77-49b4-ae6a-f2a821af74f3"",
|
||||||
|
""path"": ""<Keyboard>/a"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Keyboard"",
|
||||||
|
""action"": ""Steering"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""right"",
|
||||||
|
""id"": ""7982cd98-2174-4ba5-9336-86444014708c"",
|
||||||
|
""path"": ""<Keyboard>/d"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Keyboard"",
|
||||||
|
""action"": ""Steering"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Gamepad"",
|
||||||
|
""id"": ""7f8ea85c-3a52-47e3-865f-5f276f15d11b"",
|
||||||
|
""path"": ""1DAxis(minValue=0)"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Handbrake"",
|
||||||
|
""isComposite"": true,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Negative"",
|
||||||
|
""id"": ""d212264c-0e6d-438e-aa32-62d822de1279"",
|
||||||
|
""path"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Gamepad"",
|
||||||
|
""action"": ""Handbrake"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Positive"",
|
||||||
|
""id"": ""b71cea67-2af2-4367-b32b-4d5f2bcd7b25"",
|
||||||
|
""path"": ""<Gamepad>/buttonWest"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Gamepad"",
|
||||||
|
""action"": ""Handbrake"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Keyboard"",
|
||||||
|
""id"": ""d3e19a7d-ec2e-4908-bcfc-10ed6149e97a"",
|
||||||
|
""path"": ""1DAxis"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""Handbrake"",
|
||||||
|
""isComposite"": true,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""negative"",
|
||||||
|
""id"": ""c59d61e7-3a15-439d-87fa-8a59b5fe6437"",
|
||||||
|
""path"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Keyboard"",
|
||||||
|
""action"": ""Handbrake"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""positive"",
|
||||||
|
""id"": ""422064e0-3113-4666-b205-973375de75e0"",
|
||||||
|
""path"": ""<Keyboard>/space"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Keyboard"",
|
||||||
|
""action"": ""Handbrake"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Gamepad"",
|
||||||
|
""id"": ""14b1e5bd-e2a3-43d4-ace6-679f8a78c59c"",
|
||||||
|
""path"": ""1DAxis(minValue=0)"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""NOS"",
|
||||||
|
""isComposite"": true,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""negative"",
|
||||||
|
""id"": ""1ba3adbb-7f60-4bcd-8872-0e763afe48ff"",
|
||||||
|
""path"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Gamepad"",
|
||||||
|
""action"": ""NOS"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""positive"",
|
||||||
|
""id"": ""ce89976d-be77-4f26-b904-321317383a9c"",
|
||||||
|
""path"": ""<Gamepad>/buttonSouth"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Gamepad"",
|
||||||
|
""action"": ""NOS"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Keyboard"",
|
||||||
|
""id"": ""57f4b081-cb98-4eb6-86ce-546b71291040"",
|
||||||
|
""path"": ""1DAxis"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": """",
|
||||||
|
""action"": ""NOS"",
|
||||||
|
""isComposite"": true,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""negative"",
|
||||||
|
""id"": ""b78718e4-3099-4c95-bccc-023c98eae17d"",
|
||||||
|
""path"": """",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Keyboard"",
|
||||||
|
""action"": ""NOS"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""positive"",
|
||||||
|
""id"": ""ccc60a83-d82a-46f0-8cff-8010f269dbe4"",
|
||||||
|
""path"": ""<Keyboard>/leftShift"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Keyboard"",
|
||||||
|
""action"": ""NOS"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": """",
|
||||||
|
""id"": ""4d4b1ec5-f611-47d6-a6d3-f6d3ac447c79"",
|
||||||
|
""path"": ""<Gamepad>/start"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Gamepad"",
|
||||||
|
""action"": ""Menu"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": """",
|
||||||
|
""id"": ""efa8503e-718f-4af5-88c0-6f866190c68e"",
|
||||||
|
""path"": ""<Keyboard>/escape"",
|
||||||
|
""interactions"": """",
|
||||||
|
""processors"": """",
|
||||||
|
""groups"": ""Keyboard"",
|
||||||
|
""action"": ""Menu"",
|
||||||
|
""isComposite"": false,
|
||||||
|
""isPartOfComposite"": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
""controlSchemes"": [
|
||||||
|
{
|
||||||
|
""name"": ""Gamepad"",
|
||||||
|
""bindingGroup"": ""Gamepad"",
|
||||||
|
""devices"": [
|
||||||
|
{
|
||||||
|
""devicePath"": ""<Gamepad>"",
|
||||||
|
""isOptional"": false,
|
||||||
|
""isOR"": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
""name"": ""Keyboard"",
|
||||||
|
""bindingGroup"": ""Keyboard"",
|
||||||
|
""devices"": [
|
||||||
|
{
|
||||||
|
""devicePath"": ""<Keyboard>"",
|
||||||
|
""isOptional"": false,
|
||||||
|
""isOR"": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}");
|
||||||
|
// Vehicle
|
||||||
|
m_Vehicle = asset.FindActionMap("Vehicle", throwIfNotFound: true);
|
||||||
|
m_Vehicle_Throttle = m_Vehicle.FindAction("Throttle", throwIfNotFound: true);
|
||||||
|
m_Vehicle_Steering = m_Vehicle.FindAction("Steering", throwIfNotFound: true);
|
||||||
|
m_Vehicle_Handbrake = m_Vehicle.FindAction("Handbrake", throwIfNotFound: true);
|
||||||
|
m_Vehicle_NOS = m_Vehicle.FindAction("NOS", throwIfNotFound: true);
|
||||||
|
m_Vehicle_Menu = m_Vehicle.FindAction("Menu", throwIfNotFound: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
UnityEngine.Object.Destroy(asset);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputBinding? bindingMask
|
||||||
|
{
|
||||||
|
get => asset.bindingMask;
|
||||||
|
set => asset.bindingMask = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReadOnlyArray<InputDevice>? devices
|
||||||
|
{
|
||||||
|
get => asset.devices;
|
||||||
|
set => asset.devices = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
||||||
|
|
||||||
|
public bool Contains(InputAction action)
|
||||||
|
{
|
||||||
|
return asset.Contains(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<InputAction> GetEnumerator()
|
||||||
|
{
|
||||||
|
return asset.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Enable()
|
||||||
|
{
|
||||||
|
asset.Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Disable()
|
||||||
|
{
|
||||||
|
asset.Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<InputBinding> bindings => asset.bindings;
|
||||||
|
|
||||||
|
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
|
||||||
|
{
|
||||||
|
return asset.FindAction(actionNameOrId, throwIfNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int FindBinding(InputBinding bindingMask, out InputAction action)
|
||||||
|
{
|
||||||
|
return asset.FindBinding(bindingMask, out action);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vehicle
|
||||||
|
private readonly InputActionMap m_Vehicle;
|
||||||
|
private List<IVehicleActions> m_VehicleActionsCallbackInterfaces = new List<IVehicleActions>();
|
||||||
|
private readonly InputAction m_Vehicle_Throttle;
|
||||||
|
private readonly InputAction m_Vehicle_Steering;
|
||||||
|
private readonly InputAction m_Vehicle_Handbrake;
|
||||||
|
private readonly InputAction m_Vehicle_NOS;
|
||||||
|
private readonly InputAction m_Vehicle_Menu;
|
||||||
|
public struct VehicleActions
|
||||||
|
{
|
||||||
|
private @Test_rcc m_Wrapper;
|
||||||
|
public VehicleActions(@Test_rcc wrapper) { m_Wrapper = wrapper; }
|
||||||
|
public InputAction @Throttle => m_Wrapper.m_Vehicle_Throttle;
|
||||||
|
public InputAction @Steering => m_Wrapper.m_Vehicle_Steering;
|
||||||
|
public InputAction @Handbrake => m_Wrapper.m_Vehicle_Handbrake;
|
||||||
|
public InputAction @NOS => m_Wrapper.m_Vehicle_NOS;
|
||||||
|
public InputAction @Menu => m_Wrapper.m_Vehicle_Menu;
|
||||||
|
public InputActionMap Get() { return m_Wrapper.m_Vehicle; }
|
||||||
|
public void Enable() { Get().Enable(); }
|
||||||
|
public void Disable() { Get().Disable(); }
|
||||||
|
public bool enabled => Get().enabled;
|
||||||
|
public static implicit operator InputActionMap(VehicleActions set) { return set.Get(); }
|
||||||
|
public void AddCallbacks(IVehicleActions instance)
|
||||||
|
{
|
||||||
|
if (instance == null || m_Wrapper.m_VehicleActionsCallbackInterfaces.Contains(instance)) return;
|
||||||
|
m_Wrapper.m_VehicleActionsCallbackInterfaces.Add(instance);
|
||||||
|
@Throttle.started += instance.OnThrottle;
|
||||||
|
@Throttle.performed += instance.OnThrottle;
|
||||||
|
@Throttle.canceled += instance.OnThrottle;
|
||||||
|
@Steering.started += instance.OnSteering;
|
||||||
|
@Steering.performed += instance.OnSteering;
|
||||||
|
@Steering.canceled += instance.OnSteering;
|
||||||
|
@Handbrake.started += instance.OnHandbrake;
|
||||||
|
@Handbrake.performed += instance.OnHandbrake;
|
||||||
|
@Handbrake.canceled += instance.OnHandbrake;
|
||||||
|
@NOS.started += instance.OnNOS;
|
||||||
|
@NOS.performed += instance.OnNOS;
|
||||||
|
@NOS.canceled += instance.OnNOS;
|
||||||
|
@Menu.started += instance.OnMenu;
|
||||||
|
@Menu.performed += instance.OnMenu;
|
||||||
|
@Menu.canceled += instance.OnMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UnregisterCallbacks(IVehicleActions instance)
|
||||||
|
{
|
||||||
|
@Throttle.started -= instance.OnThrottle;
|
||||||
|
@Throttle.performed -= instance.OnThrottle;
|
||||||
|
@Throttle.canceled -= instance.OnThrottle;
|
||||||
|
@Steering.started -= instance.OnSteering;
|
||||||
|
@Steering.performed -= instance.OnSteering;
|
||||||
|
@Steering.canceled -= instance.OnSteering;
|
||||||
|
@Handbrake.started -= instance.OnHandbrake;
|
||||||
|
@Handbrake.performed -= instance.OnHandbrake;
|
||||||
|
@Handbrake.canceled -= instance.OnHandbrake;
|
||||||
|
@NOS.started -= instance.OnNOS;
|
||||||
|
@NOS.performed -= instance.OnNOS;
|
||||||
|
@NOS.canceled -= instance.OnNOS;
|
||||||
|
@Menu.started -= instance.OnMenu;
|
||||||
|
@Menu.performed -= instance.OnMenu;
|
||||||
|
@Menu.canceled -= instance.OnMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveCallbacks(IVehicleActions instance)
|
||||||
|
{
|
||||||
|
if (m_Wrapper.m_VehicleActionsCallbackInterfaces.Remove(instance))
|
||||||
|
UnregisterCallbacks(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetCallbacks(IVehicleActions instance)
|
||||||
|
{
|
||||||
|
foreach (var item in m_Wrapper.m_VehicleActionsCallbackInterfaces)
|
||||||
|
UnregisterCallbacks(item);
|
||||||
|
m_Wrapper.m_VehicleActionsCallbackInterfaces.Clear();
|
||||||
|
AddCallbacks(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public VehicleActions @Vehicle => new VehicleActions(this);
|
||||||
|
private int m_GamepadSchemeIndex = -1;
|
||||||
|
public InputControlScheme GamepadScheme
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_GamepadSchemeIndex == -1) m_GamepadSchemeIndex = asset.FindControlSchemeIndex("Gamepad");
|
||||||
|
return asset.controlSchemes[m_GamepadSchemeIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int m_KeyboardSchemeIndex = -1;
|
||||||
|
public InputControlScheme KeyboardScheme
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_KeyboardSchemeIndex == -1) m_KeyboardSchemeIndex = asset.FindControlSchemeIndex("Keyboard");
|
||||||
|
return asset.controlSchemes[m_KeyboardSchemeIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public interface IVehicleActions
|
||||||
|
{
|
||||||
|
void OnThrottle(InputAction.CallbackContext context);
|
||||||
|
void OnSteering(InputAction.CallbackContext context);
|
||||||
|
void OnHandbrake(InputAction.CallbackContext context);
|
||||||
|
void OnNOS(InputAction.CallbackContext context);
|
||||||
|
void OnMenu(InputAction.CallbackContext context);
|
||||||
|
}
|
||||||
|
}
|
11
Assets/RealisticCarControllerV3/Resources/test_rcc.cs.meta
Normal file
11
Assets/RealisticCarControllerV3/Resources/test_rcc.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 88c4bb008f1e11f42a25481ffc83d3d8
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -8,7 +8,7 @@ ScriptedImporter:
|
|||||||
assetBundleName:
|
assetBundleName:
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
||||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||||
generateWrapperCode: 0
|
generateWrapperCode: 1
|
||||||
wrapperCodePath:
|
wrapperCodePath:
|
||||||
wrapperClassName:
|
wrapperClassName:
|
||||||
wrapperCodeNamespace:
|
wrapperCodeNamespace:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user