namespace 설정 오류 수정
This commit is contained in:
@@ -3,61 +3,66 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
public class VariableJoystick : Joystick
|
|
||||||
|
namespace TON
|
||||||
{
|
{
|
||||||
public float MoveThreshold { get { return moveThreshold; } set { moveThreshold = Mathf.Abs(value); } }
|
|
||||||
|
|
||||||
[SerializeField] private float moveThreshold = 1;
|
public class VariableJoystick : Joystick
|
||||||
[SerializeField] private JoystickType joystickType = JoystickType.Fixed;
|
|
||||||
|
|
||||||
private Vector2 fixedPosition = Vector2.zero;
|
|
||||||
|
|
||||||
public void SetMode(JoystickType joystickType)
|
|
||||||
{
|
{
|
||||||
this.joystickType = joystickType;
|
public float MoveThreshold { get { return moveThreshold; } set { moveThreshold = Mathf.Abs(value); } }
|
||||||
if (joystickType == JoystickType.Fixed)
|
|
||||||
|
[SerializeField] private float moveThreshold = 1;
|
||||||
|
[SerializeField] private JoystickType joystickType = JoystickType.Fixed;
|
||||||
|
|
||||||
|
private Vector2 fixedPosition = Vector2.zero;
|
||||||
|
|
||||||
|
public void SetMode(JoystickType joystickType)
|
||||||
{
|
{
|
||||||
background.anchoredPosition = fixedPosition;
|
this.joystickType = joystickType;
|
||||||
background.gameObject.SetActive(true);
|
if (joystickType == JoystickType.Fixed)
|
||||||
|
{
|
||||||
|
background.anchoredPosition = fixedPosition;
|
||||||
|
background.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
background.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
background.gameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Start()
|
protected override void Start()
|
||||||
{
|
|
||||||
base.Start();
|
|
||||||
fixedPosition = background.anchoredPosition;
|
|
||||||
SetMode(joystickType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPointerDown(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (joystickType != JoystickType.Fixed)
|
|
||||||
{
|
{
|
||||||
background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
base.Start();
|
||||||
background.gameObject.SetActive(true);
|
fixedPosition = background.anchoredPosition;
|
||||||
|
SetMode(joystickType);
|
||||||
}
|
}
|
||||||
base.OnPointerDown(eventData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPointerUp(PointerEventData eventData)
|
public override void OnPointerDown(PointerEventData eventData)
|
||||||
{
|
|
||||||
if (joystickType != JoystickType.Fixed)
|
|
||||||
background.gameObject.SetActive(false);
|
|
||||||
|
|
||||||
base.OnPointerUp(eventData);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void HandleInput(float magnitude, Vector2 normalised, Vector2 radius, Camera cam)
|
|
||||||
{
|
|
||||||
if (joystickType == JoystickType.Dynamic && magnitude > moveThreshold)
|
|
||||||
{
|
{
|
||||||
Vector2 difference = normalised * (magnitude - moveThreshold) * radius;
|
if (joystickType != JoystickType.Fixed)
|
||||||
background.anchoredPosition += difference;
|
{
|
||||||
|
background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
||||||
|
background.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
base.OnPointerDown(eventData);
|
||||||
}
|
}
|
||||||
base.HandleInput(magnitude, normalised, radius, cam);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum JoystickType { Fixed, Floating, Dynamic }
|
public override void OnPointerUp(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (joystickType != JoystickType.Fixed)
|
||||||
|
background.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
base.OnPointerUp(eventData);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void HandleInput(float magnitude, Vector2 normalised, Vector2 radius, Camera cam)
|
||||||
|
{
|
||||||
|
if (joystickType == JoystickType.Dynamic && magnitude > moveThreshold)
|
||||||
|
{
|
||||||
|
Vector2 difference = normalised * (magnitude - moveThreshold) * radius;
|
||||||
|
background.anchoredPosition += difference;
|
||||||
|
}
|
||||||
|
base.HandleInput(magnitude, normalised, radius, cam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum JoystickType { Fixed, Floating, Dynamic }
|
||||||
|
}
|
||||||
@@ -3,64 +3,62 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace TON
|
|
||||||
|
public class VariableJoystick : Joystick
|
||||||
{
|
{
|
||||||
public class VariableJoystick : Joystick
|
public float MoveThreshold { get { return moveThreshold; } set { moveThreshold = Mathf.Abs(value); } }
|
||||||
|
|
||||||
|
[SerializeField] private float moveThreshold = 1;
|
||||||
|
[SerializeField] private JoystickType joystickType = JoystickType.Fixed;
|
||||||
|
|
||||||
|
private Vector2 fixedPosition = Vector2.zero;
|
||||||
|
|
||||||
|
public void SetMode(JoystickType joystickType)
|
||||||
{
|
{
|
||||||
public float MoveThreshold { get { return moveThreshold; } set { moveThreshold = Mathf.Abs(value); } }
|
this.joystickType = joystickType;
|
||||||
|
if (joystickType == JoystickType.Fixed)
|
||||||
[SerializeField] private float moveThreshold = 1;
|
|
||||||
[SerializeField] private JoystickType joystickType = JoystickType.Fixed;
|
|
||||||
|
|
||||||
private Vector2 fixedPosition = Vector2.zero;
|
|
||||||
|
|
||||||
public void SetMode(JoystickType joystickType)
|
|
||||||
{
|
{
|
||||||
this.joystickType = joystickType;
|
background.anchoredPosition = fixedPosition;
|
||||||
if (joystickType == JoystickType.Fixed)
|
background.gameObject.SetActive(true);
|
||||||
{
|
|
||||||
background.anchoredPosition = fixedPosition;
|
|
||||||
background.gameObject.SetActive(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
background.gameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Start()
|
|
||||||
{
|
|
||||||
base.Start();
|
|
||||||
fixedPosition = background.anchoredPosition;
|
|
||||||
SetMode(joystickType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPointerDown(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (joystickType != JoystickType.Fixed)
|
|
||||||
{
|
|
||||||
background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
|
||||||
background.gameObject.SetActive(true);
|
|
||||||
}
|
|
||||||
base.OnPointerDown(eventData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnPointerUp(PointerEventData eventData)
|
|
||||||
{
|
|
||||||
if (joystickType != JoystickType.Fixed)
|
|
||||||
background.gameObject.SetActive(false);
|
|
||||||
|
|
||||||
base.OnPointerUp(eventData);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void HandleInput(float magnitude, Vector2 normalised, Vector2 radius, Camera cam)
|
|
||||||
{
|
|
||||||
if (joystickType == JoystickType.Dynamic && magnitude > moveThreshold)
|
|
||||||
{
|
|
||||||
Vector2 difference = normalised * (magnitude - moveThreshold) * radius;
|
|
||||||
background.anchoredPosition += difference;
|
|
||||||
}
|
|
||||||
base.HandleInput(magnitude, normalised, radius, cam);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
background.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum JoystickType { Fixed, Floating, Dynamic }
|
protected override void Start()
|
||||||
}
|
{
|
||||||
|
base.Start();
|
||||||
|
fixedPosition = background.anchoredPosition;
|
||||||
|
SetMode(joystickType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnPointerDown(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (joystickType != JoystickType.Fixed)
|
||||||
|
{
|
||||||
|
background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
||||||
|
background.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
base.OnPointerDown(eventData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnPointerUp(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
if (joystickType != JoystickType.Fixed)
|
||||||
|
background.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
base.OnPointerUp(eventData);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void HandleInput(float magnitude, Vector2 normalised, Vector2 radius, Camera cam)
|
||||||
|
{
|
||||||
|
if (joystickType == JoystickType.Dynamic && magnitude > moveThreshold)
|
||||||
|
{
|
||||||
|
Vector2 difference = normalised * (magnitude - moveThreshold) * radius;
|
||||||
|
background.anchoredPosition += difference;
|
||||||
|
}
|
||||||
|
base.HandleInput(magnitude, normalised, radius, cam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum JoystickType { Fixed, Floating, Dynamic }
|
||||||
|
|||||||
Reference in New Issue
Block a user