Make work with astra
This commit is contained in:
parent
21859bcfb3
commit
c8ee5045e2
6 changed files with 6338 additions and 4613 deletions
|
|
@ -1,5 +1,376 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3369231b1ed7ad34e84d9240a571db81
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &100000
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22400000}
|
||||
- 223: {fileID: 22300000}
|
||||
- 114: {fileID: 11400000}
|
||||
- 114: {fileID: 11400012}
|
||||
m_Layer: 5
|
||||
m_Name: MobileSingleStickControl
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!1 &100002
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22400002}
|
||||
- 222: {fileID: 22200002}
|
||||
- 114: {fileID: 11400010}
|
||||
- 114: {fileID: 11400008}
|
||||
m_Layer: 5
|
||||
m_Name: MobileJoystick
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!1 &100004
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22400004}
|
||||
- 222: {fileID: 22200000}
|
||||
- 114: {fileID: 11400006}
|
||||
- 114: {fileID: 11400004}
|
||||
- 114: {fileID: 11400002}
|
||||
m_Layer: 5
|
||||
m_Name: JumpButton
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!1 &100006
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22400006}
|
||||
- 222: {fileID: 22200004}
|
||||
- 114: {fileID: 11400016}
|
||||
- 114: {fileID: 11400014}
|
||||
m_Layer: 5
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100000}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
ignoreReversedGraphics: 1
|
||||
blockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &11400002
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100004}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 85bf3be603548374ca46f521a3aa7fda, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Name: Jump
|
||||
--- !u!114 &11400004
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100004}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -1862395651, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
delegates:
|
||||
- eventID: 2
|
||||
callback:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 11400002}
|
||||
m_MethodName: SetDownState
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine, Version=0.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=null
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument: Jump
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 1
|
||||
m_TypeName: UnityEngine.EventSystems.EventTrigger+TriggerEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
- eventID: 3
|
||||
callback:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 11400002}
|
||||
m_MethodName: SetUpState
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine, Version=0.0.0.0,
|
||||
Culture=neutral, PublicKeyToken=null
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument: Jump
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 1
|
||||
m_TypeName: UnityEngine.EventSystems.EventTrigger+TriggerEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
--- !u!114 &11400006
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100004}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Sprite: {fileID: 21300000, guid: 3d8675433a508ec47b8f895201eacf20, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
--- !u!114 &11400008
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100002}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 00c3c865782347f41b6358d9fba14b48, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
MovementRange: 100
|
||||
axesToUse: 0
|
||||
horizontalAxisName: Horizontal
|
||||
verticalAxisName: Vertical
|
||||
--- !u!114 &11400010
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100002}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Sprite: {fileID: 21300000, guid: 9866a92691696b346901281f2b329034, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
--- !u!114 &11400012
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100000}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 71398ce7fbc3a5b4fa50b50bd54317a7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &11400014
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100006}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1573420865, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_EffectColor: {r: 0, g: 0, b: 0, a: .125490203}
|
||||
m_EffectDistance: {x: 2, y: -2}
|
||||
m_UseGraphicAlpha: 1
|
||||
--- !u!114 &11400016
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100006}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: .643137276}
|
||||
m_FontData:
|
||||
m_Font: {fileID: 12800000, guid: 01cd679a1b9ee48bf9c546f6ce2cb97e, type: 3}
|
||||
m_FontSize: 26
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 10
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Jump
|
||||
--- !u!222 &22200000
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100004}
|
||||
--- !u!222 &22200002
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100002}
|
||||
--- !u!222 &22200004
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100006}
|
||||
--- !u!223 &22300000
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100000}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 1
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!224 &22400000
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100000}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_Children:
|
||||
- {fileID: 22400004}
|
||||
- {fileID: 22400002}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!224 &22400002
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100002}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22400000}
|
||||
m_RootOrder: 1
|
||||
m_AnchorMin: {x: .160000011, y: .200000003}
|
||||
m_AnchorMax: {x: .160000011, y: .200000003}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 80, y: 80}
|
||||
m_Pivot: {x: .5, y: .5}
|
||||
--- !u!224 &22400004
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100004}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 22400006}
|
||||
m_Father: {fileID: 22400000}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: .779999971, y: .00999999978}
|
||||
m_AnchorMax: {x: .99000001, y: .150000006}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: .5, y: .5}
|
||||
--- !u!224 &22400006
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 100006}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 22400004}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: .5, y: .5}
|
||||
--- !u!1001 &100100000
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 1
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications: []
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 0}
|
||||
m_RootGameObject: {fileID: 100000}
|
||||
m_IsPrefabParent: 1
|
||||
|
|
|
|||
|
|
@ -1,118 +1,9 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UnityStandardAssets.CrossPlatformInput
|
||||
{
|
||||
public class Joystick : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler
|
||||
{
|
||||
public enum AxisOption
|
||||
{
|
||||
// Options for which axes to use
|
||||
Both, // Use both
|
||||
OnlyHorizontal, // Only horizontal
|
||||
OnlyVertical // Only vertical
|
||||
}
|
||||
|
||||
public int MovementRange = 100;
|
||||
public AxisOption axesToUse = AxisOption.Both; // The options for the axes that the still will use
|
||||
public string horizontalAxisName = "Horizontal"; // The name given to the horizontal axis for the cross platform input
|
||||
public string verticalAxisName = "Vertical"; // The name given to the vertical axis for the cross platform input
|
||||
|
||||
Vector3 m_StartPos;
|
||||
bool m_UseX; // Toggle for using the x axis
|
||||
bool m_UseY; // Toggle for using the Y axis
|
||||
CrossPlatformInputManager.VirtualAxis m_HorizontalVirtualAxis; // Reference to the joystick in the cross platform input
|
||||
CrossPlatformInputManager.VirtualAxis m_VerticalVirtualAxis; // Reference to the joystick in the cross platform input
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
CreateVirtualAxes();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
m_StartPos = transform.position;
|
||||
}
|
||||
|
||||
void UpdateVirtualAxes(Vector3 value)
|
||||
{
|
||||
var delta = m_StartPos - value;
|
||||
delta.y = -delta.y;
|
||||
delta /= MovementRange;
|
||||
if (m_UseX)
|
||||
{
|
||||
m_HorizontalVirtualAxis.Update(-delta.x);
|
||||
}
|
||||
|
||||
if (m_UseY)
|
||||
{
|
||||
m_VerticalVirtualAxis.Update(delta.y);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateVirtualAxes()
|
||||
{
|
||||
// set axes to use
|
||||
m_UseX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal);
|
||||
m_UseY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical);
|
||||
|
||||
// create new axes based on axes to use
|
||||
if (m_UseX)
|
||||
{
|
||||
m_HorizontalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(horizontalAxisName);
|
||||
CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis);
|
||||
}
|
||||
if (m_UseY)
|
||||
{
|
||||
m_VerticalVirtualAxis = new CrossPlatformInputManager.VirtualAxis(verticalAxisName);
|
||||
CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnDrag(PointerEventData data)
|
||||
{
|
||||
Vector3 newPos = Vector3.zero;
|
||||
|
||||
if (m_UseX)
|
||||
{
|
||||
int delta = (int)(data.position.x - m_StartPos.x);
|
||||
delta = Mathf.Clamp(delta, - MovementRange, MovementRange);
|
||||
newPos.x = delta;
|
||||
}
|
||||
|
||||
if (m_UseY)
|
||||
{
|
||||
int delta = (int)(data.position.y - m_StartPos.y);
|
||||
delta = Mathf.Clamp(delta, -MovementRange, MovementRange);
|
||||
newPos.y = delta;
|
||||
}
|
||||
transform.position = new Vector3(m_StartPos.x + newPos.x, m_StartPos.y + newPos.y, m_StartPos.z + newPos.z);
|
||||
UpdateVirtualAxes(transform.position);
|
||||
}
|
||||
|
||||
|
||||
public void OnPointerUp(PointerEventData data)
|
||||
{
|
||||
transform.position = m_StartPos;
|
||||
UpdateVirtualAxes(m_StartPos);
|
||||
}
|
||||
|
||||
|
||||
public void OnPointerDown(PointerEventData data) { }
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
// remove the joysticks from the cross platform input
|
||||
if (m_UseX)
|
||||
{
|
||||
m_HorizontalVirtualAxis.Remove();
|
||||
}
|
||||
if (m_UseY)
|
||||
{
|
||||
m_VerticalVirtualAxis.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fileFormatVersion: 2
|
||||
guid: 7d3269566d48b8447bb48d2259e28f8b
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,134 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1caf40fc8bebb6b43b2550c05ca791d6
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace UnityStandardAssets.CrossPlatformInput
|
||||
{
|
||||
public abstract class VirtualInput
|
||||
{
|
||||
public Vector3 virtualMousePosition { get; private set; }
|
||||
|
||||
|
||||
protected Dictionary<string, CrossPlatformInputManager.VirtualAxis> m_VirtualAxes =
|
||||
new Dictionary<string, CrossPlatformInputManager.VirtualAxis>();
|
||||
// Dictionary to store the name relating to the virtual axes
|
||||
protected Dictionary<string, CrossPlatformInputManager.VirtualButton> m_VirtualButtons =
|
||||
new Dictionary<string, CrossPlatformInputManager.VirtualButton>();
|
||||
protected List<string> m_AlwaysUseVirtual = new List<string>();
|
||||
// list of the axis and button names that have been flagged to always use a virtual axis or button
|
||||
|
||||
|
||||
public bool AxisExists(string name)
|
||||
{
|
||||
return m_VirtualAxes.ContainsKey(name);
|
||||
}
|
||||
|
||||
public bool ButtonExists(string name)
|
||||
{
|
||||
return m_VirtualButtons.ContainsKey(name);
|
||||
}
|
||||
|
||||
|
||||
public void RegisterVirtualAxis(CrossPlatformInputManager.VirtualAxis axis)
|
||||
{
|
||||
// check if we already have an axis with that name and log and error if we do
|
||||
if (m_VirtualAxes.ContainsKey(axis.name))
|
||||
{
|
||||
Debug.LogError("There is already a virtual axis named " + axis.name + " registered.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// add any new axes
|
||||
m_VirtualAxes.Add(axis.name, axis);
|
||||
|
||||
// if we dont want to match with the input manager setting then revert to always using virtual
|
||||
if (!axis.matchWithInputManager)
|
||||
{
|
||||
m_AlwaysUseVirtual.Add(axis.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RegisterVirtualButton(CrossPlatformInputManager.VirtualButton button)
|
||||
{
|
||||
// check if already have a buttin with that name and log an error if we do
|
||||
if (m_VirtualButtons.ContainsKey(button.name))
|
||||
{
|
||||
Debug.LogError("There is already a virtual button named " + button.name + " registered.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// add any new buttons
|
||||
m_VirtualButtons.Add(button.name, button);
|
||||
|
||||
// if we dont want to match to the input manager then always use a virtual axis
|
||||
if (!button.matchWithInputManager)
|
||||
{
|
||||
m_AlwaysUseVirtual.Add(button.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UnRegisterVirtualAxis(string name)
|
||||
{
|
||||
// if we have an axis with that name then remove it from our dictionary of registered axes
|
||||
if (m_VirtualAxes.ContainsKey(name))
|
||||
{
|
||||
m_VirtualAxes.Remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UnRegisterVirtualButton(string name)
|
||||
{
|
||||
// if we have a button with this name then remove it from our dictionary of registered buttons
|
||||
if (m_VirtualButtons.ContainsKey(name))
|
||||
{
|
||||
m_VirtualButtons.Remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// returns a reference to a named virtual axis if it exists otherwise null
|
||||
public CrossPlatformInputManager.VirtualAxis VirtualAxisReference(string name)
|
||||
{
|
||||
return m_VirtualAxes.ContainsKey(name) ? m_VirtualAxes[name] : null;
|
||||
}
|
||||
|
||||
|
||||
public void SetVirtualMousePositionX(float f)
|
||||
{
|
||||
virtualMousePosition = new Vector3(f, virtualMousePosition.y, virtualMousePosition.z);
|
||||
}
|
||||
|
||||
|
||||
public void SetVirtualMousePositionY(float f)
|
||||
{
|
||||
virtualMousePosition = new Vector3(virtualMousePosition.x, f, virtualMousePosition.z);
|
||||
}
|
||||
|
||||
|
||||
public void SetVirtualMousePositionZ(float f)
|
||||
{
|
||||
virtualMousePosition = new Vector3(virtualMousePosition.x, virtualMousePosition.y, f);
|
||||
}
|
||||
|
||||
|
||||
public abstract float GetAxis(string name, bool raw);
|
||||
|
||||
public abstract bool GetButton(string name);
|
||||
public abstract bool GetButtonDown(string name);
|
||||
public abstract bool GetButtonUp(string name);
|
||||
|
||||
public abstract void SetButtonDown(string name);
|
||||
public abstract void SetButtonUp(string name);
|
||||
public abstract void SetAxisPositive(string name);
|
||||
public abstract void SetAxisNegative(string name);
|
||||
public abstract void SetAxisZero(string name);
|
||||
public abstract void SetAxis(string name, float value);
|
||||
public abstract Vector3 MousePosition();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 8.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in a new issue