Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
34b8900dce | ||
![]() |
5a736a8335 | ||
![]() |
58e6c64618 | ||
![]() |
a2bd0c5927 | ||
![]() |
b21b000880 | ||
![]() |
90292f1012 | ||
![]() |
ed38351ba4 | ||
![]() |
04652acfa5 | ||
![]() |
3bbdd7e5f4 | ||
![]() |
aa3187745b | ||
![]() |
e630b2f332 | ||
![]() |
6631d3a3a4 | ||
![]() |
854b093f45 | ||
![]() |
76426859a2 |
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -63,3 +63,4 @@
|
||||
*.reason filter=lfs diff=lfs merge=lfs -text
|
||||
*.lxo filter=lfs diff=lfs merge=lfs -text
|
||||
*.anim filter=lfs diff=lfs merge=lfs -text
|
||||
*.unity filter=lfs diff=lfs merge=lfs -text
|
||||
|
41
.vscode/launch.json
vendored
41
.vscode/launch.json
vendored
@ -1,41 +0,0 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"WARNING01": "*********************************************************************************",
|
||||
"WARNING02": "The C# extension was unable to automatically decode projects in the current",
|
||||
"WARNING03": "workspace to create a runnable launch.json file. A template launch.json file has",
|
||||
"WARNING04": "been created as a placeholder.",
|
||||
"WARNING05": "",
|
||||
"WARNING06": "If OmniSharp is currently unable to load your project, you can attempt to resolve",
|
||||
"WARNING07": "this by restoring any missing project dependencies (example: run 'dotnet restore')",
|
||||
"WARNING08": "and by fixing any reported errors from building the projects in your workspace.",
|
||||
"WARNING09": "If this allows OmniSharp to now load your project then --",
|
||||
"WARNING10": " * Delete this file",
|
||||
"WARNING11": " * Open the Visual Studio Code command palette (View->Command Palette)",
|
||||
"WARNING12": " * run the command: '.NET: Generate Assets for Build and Debug'.",
|
||||
"WARNING13": "",
|
||||
"WARNING14": "If your project requires a more complex launch configuration, you may wish to delete",
|
||||
"WARNING15": "this configuration and pick a different template using the 'Add Configuration...'",
|
||||
"WARNING16": "button at the bottom of this file.",
|
||||
"WARNING17": "*********************************************************************************",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"console": "internalConsole",
|
||||
"stopAtEntry": false
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach"
|
||||
}
|
||||
]
|
||||
}
|
56
.vscode/settings.json
vendored
56
.vscode/settings.json
vendored
@ -1,56 +0,0 @@
|
||||
{
|
||||
"files.exclude":
|
||||
{
|
||||
"**/.DS_Store":true,
|
||||
"**/.git":true,
|
||||
"**/.gitignore":true,
|
||||
"**/.gitmodules":true,
|
||||
"**/*.booproj":true,
|
||||
"**/*.pidb":true,
|
||||
"**/*.suo":true,
|
||||
"**/*.user":true,
|
||||
"**/*.userprefs":true,
|
||||
"**/*.unityproj":true,
|
||||
"**/*.dll":true,
|
||||
"**/*.exe":true,
|
||||
"**/*.pdf":true,
|
||||
"**/*.mid":true,
|
||||
"**/*.midi":true,
|
||||
"**/*.wav":true,
|
||||
"**/*.gif":true,
|
||||
"**/*.ico":true,
|
||||
"**/*.jpg":true,
|
||||
"**/*.jpeg":true,
|
||||
"**/*.png":true,
|
||||
"**/*.psd":true,
|
||||
"**/*.tga":true,
|
||||
"**/*.tif":true,
|
||||
"**/*.tiff":true,
|
||||
"**/*.3ds":true,
|
||||
"**/*.3DS":true,
|
||||
"**/*.fbx":true,
|
||||
"**/*.FBX":true,
|
||||
"**/*.lxo":true,
|
||||
"**/*.LXO":true,
|
||||
"**/*.ma":true,
|
||||
"**/*.MA":true,
|
||||
"**/*.obj":true,
|
||||
"**/*.OBJ":true,
|
||||
"**/*.asset":true,
|
||||
"**/*.cubemap":true,
|
||||
"**/*.flare":true,
|
||||
"**/*.mat":true,
|
||||
"**/*.meta":true,
|
||||
"**/*.prefab":true,
|
||||
"**/*.unity":true,
|
||||
"build/":true,
|
||||
"Build/":true,
|
||||
"Library/":true,
|
||||
"library/":true,
|
||||
"obj/":true,
|
||||
"Obj/":true,
|
||||
"ProjectSettings/":true,
|
||||
"temp/":true,
|
||||
"Temp/":true
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"components": [
|
||||
"Microsoft.VisualStudio.Workload.ManagedGame"
|
||||
]
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c80bdd8512f62940a7e17ae649792a6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2b0fa72583c0e374a8ae47bcfda2c9da01a520f00d911fbabe439e21c0ce2c95
|
||||
size 38513
|
@ -1,96 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6147df1c2f0c534b98bf1a43ec25237
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 0
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,79 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Invisible
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: 3000
|
||||
stringTagMap:
|
||||
RenderType: Transparent
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 10
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 3
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 0.08627451}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 021ce5359e648764395415a8668a2094
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90d84c17433560f4b9af127c5ef1a4ad
|
||||
guid: edecf53c59f785748936df14e96cff78
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -56,17 +56,17 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 8170153791668043269}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 0}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
@ -76,6 +76,7 @@ MonoBehaviour:
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &8170153791668043265
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -130,7 +131,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 128, y: 128}
|
||||
m_SizeDelta: {x: 50, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8170153791961219458
|
||||
CanvasRenderer:
|
||||
@ -149,18 +150,18 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 8170153791961219457}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_Sprite: {fileID: 21300000, guid: 010a6e5305fa7004f89c5d317b7b47d4, type: 3}
|
||||
m_Sprite: {fileID: 21300000, guid: e4cafc2ebb0780147b883e0519c14216, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
@ -169,6 +170,7 @@ MonoBehaviour:
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &8170153792821263259
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -204,8 +206,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 256, y: 256}
|
||||
m_SizeDelta: {x: 256, y: 256}
|
||||
m_AnchoredPosition: {x: 100, y: 100}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8170153792821263255
|
||||
CanvasRenderer:
|
||||
@ -224,18 +226,18 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 8170153792821263259}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_Sprite: {fileID: 21300000, guid: 5b56d9fa0e8bd6e409ed188db38a692c, type: 3}
|
||||
m_Sprite: {fileID: 21300000, guid: 762431f3bc929244dbafb8adebe33a20, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
@ -244,3 +246,4 @@ MonoBehaviour:
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPointerUpHandler
|
||||
{
|
||||
@ -34,28 +34,17 @@ public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPoint
|
||||
|
||||
[SerializeField] protected RectTransform background = null;
|
||||
[SerializeField] private RectTransform handle = null;
|
||||
[HideInInspector] public Action<Vector3> OnPadDrag;
|
||||
private RectTransform baseRect = null;
|
||||
[SerializeField] private bool isToTranparency = false;
|
||||
|
||||
[SerializeField] private float timeToFade;
|
||||
[SerializeField] private float transparency;
|
||||
|
||||
|
||||
public event Action OnTouchUp;
|
||||
public event Action OnTouchDown;
|
||||
public event Action<Vector2> OnDrug;
|
||||
public bool isJoysticDirectionZero;
|
||||
|
||||
private Canvas canvas;
|
||||
private Camera cam;
|
||||
private bool _isPressed;
|
||||
|
||||
public bool IsPressed => _isPressed;
|
||||
|
||||
private Vector2 input = Vector2.zero;
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
//IsTouchedUP = true;
|
||||
HandleRange = handleRange;
|
||||
DeadZone = deadZone;
|
||||
baseRect = GetComponent<RectTransform>();
|
||||
@ -69,14 +58,11 @@ public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPoint
|
||||
handle.anchorMax = center;
|
||||
handle.pivot = center;
|
||||
handle.anchoredPosition = Vector2.zero;
|
||||
_isPressed = false;
|
||||
}
|
||||
|
||||
public virtual void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
OnDrag(eventData);
|
||||
OnTouchDown?.Invoke();
|
||||
_isPressed = true;
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
@ -91,9 +77,7 @@ public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPoint
|
||||
FormatInput();
|
||||
HandleInput(input.magnitude, input.normalized, radius, cam);
|
||||
handle.anchoredPosition = input * radius * handleRange;
|
||||
isJoysticDirectionZero = Direction.Equals(Vector2.zero);
|
||||
|
||||
OnDrug?.Invoke(Direction);
|
||||
OnPadDrag?.Invoke(Direction);
|
||||
}
|
||||
|
||||
protected virtual void HandleInput(float magnitude, Vector2 normalised, Vector2 radius, Camera cam)
|
||||
@ -153,8 +137,7 @@ public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPoint
|
||||
{
|
||||
input = Vector2.zero;
|
||||
handle.anchoredPosition = Vector2.zero;
|
||||
OnTouchUp?.Invoke();
|
||||
_isPressed = false;
|
||||
|
||||
}
|
||||
|
||||
protected Vector2 ScreenPointToAnchoredPosition(Vector2 screenPosition)
|
||||
@ -167,20 +150,6 @@ public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPoint
|
||||
}
|
||||
return Vector2.zero;
|
||||
}
|
||||
|
||||
protected void FadeJoystick(bool isToTransparant)
|
||||
{
|
||||
if (!isToTransparant)
|
||||
{
|
||||
background.gameObject.GetComponent<Image>().DOFade(transparency, timeToFade);
|
||||
handle.gameObject.GetComponent<Image>().DOFade(transparency, timeToFade);
|
||||
}
|
||||
else
|
||||
{
|
||||
background.gameObject.GetComponent<Image>().DOFade(1f, timeToFade);
|
||||
handle.gameObject.GetComponent<Image>().DOFade(1f, timeToFade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum AxisOptions { Both, Horizontal, Vertical }
|
@ -4,7 +4,7 @@ using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[CustomEditor(typeof(Joystick), true)]
|
||||
public class JoystickEditor : UnityEditor.Editor
|
||||
public class JoystickEditor : Editor
|
||||
{
|
||||
private SerializedProperty handleRange;
|
||||
private SerializedProperty deadZone;
|
||||
@ -13,9 +13,6 @@ public class JoystickEditor : UnityEditor.Editor
|
||||
private SerializedProperty snapY;
|
||||
protected SerializedProperty background;
|
||||
private SerializedProperty handle;
|
||||
private SerializedProperty timeToFade;
|
||||
private SerializedProperty transparency;
|
||||
private SerializedProperty isToTranparency;
|
||||
|
||||
protected Vector2 center = new Vector2(0.5f, 0.5f);
|
||||
|
||||
@ -28,9 +25,6 @@ public class JoystickEditor : UnityEditor.Editor
|
||||
snapY = serializedObject.FindProperty("snapY");
|
||||
background = serializedObject.FindProperty("background");
|
||||
handle = serializedObject.FindProperty("handle");
|
||||
isToTranparency = serializedObject.FindProperty("isToTranparency");
|
||||
timeToFade = serializedObject.FindProperty("timeToFade");
|
||||
transparency = serializedObject.FindProperty("transparency");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
@ -60,12 +54,6 @@ public class JoystickEditor : UnityEditor.Editor
|
||||
EditorGUILayout.PropertyField(axisOptions, new GUIContent("Axis Options", "Which axes the joystick uses."));
|
||||
EditorGUILayout.PropertyField(snapX, new GUIContent("Snap X", "Snap the horizontal input to a whole value."));
|
||||
EditorGUILayout.PropertyField(snapY, new GUIContent("Snap Y", "Snap the vertical input to a whole value."));
|
||||
EditorGUILayout.PropertyField(isToTranparency, new GUIContent("IsTranperancy", "Pick, if joystick has to be visible tranparently while inactive"));
|
||||
if (isToTranparency.boolValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(timeToFade, new GUIContent("Fade time", "Time to made joystick transparant"));
|
||||
EditorGUILayout.PropertyField(transparency, new GUIContent("Transparency"));
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DrawComponents()
|
41
Assets/Joystick Pack/Scripts/Joysticks/DynamicJoystick.cs
Normal file
41
Assets/Joystick Pack/Scripts/Joysticks/DynamicJoystick.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class DynamicJoystick : Joystick
|
||||
{
|
||||
public float MoveThreshold { get { return moveThreshold; } set { moveThreshold = Mathf.Abs(value); } }
|
||||
|
||||
[SerializeField] private float moveThreshold = 1;
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
MoveThreshold = moveThreshold;
|
||||
base.Start();
|
||||
background.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public override void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
||||
background.gameObject.SetActive(true);
|
||||
base.OnPointerDown(eventData);
|
||||
}
|
||||
|
||||
public override void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
background.gameObject.SetActive(false);
|
||||
base.OnPointerUp(eventData);
|
||||
}
|
||||
|
||||
protected override void HandleInput(float magnitude, Vector2 normalised, Vector2 radius, Camera cam)
|
||||
{
|
||||
if (magnitude > moveThreshold)
|
||||
{
|
||||
Vector2 difference = normalised * (magnitude - moveThreshold) * radius;
|
||||
background.anchoredPosition += difference;
|
||||
}
|
||||
base.HandleInput(magnitude, normalised, radius, cam);
|
||||
}
|
||||
}
|
35
Assets/Joystick Pack/Scripts/Joysticks/FloatingJoystick.cs
Normal file
35
Assets/Joystick Pack/Scripts/Joysticks/FloatingJoystick.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class FloatingJoystick : Joystick
|
||||
{
|
||||
public Action OnTouchDown, OnTouchUp;
|
||||
|
||||
public bool isPressed { get; set; }
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
background.gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
|
||||
public override void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
||||
background.gameObject.SetActive(true);
|
||||
base.OnPointerDown(eventData);
|
||||
isPressed = true;
|
||||
OnTouchDown?.Invoke();
|
||||
}
|
||||
|
||||
public override void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
background.gameObject.SetActive(false);
|
||||
isPressed = false;
|
||||
base.OnPointerUp(eventData);
|
||||
OnTouchUp?.Invoke();
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 033b10cc11a86054e9bc0e1dd384c124
|
||||
guid: 3b698f409d8c34e47b671f6ea678ab7b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aeb2b75ad02b7c142aa0a1ac80a984ff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cdac693480c1cb443b89bf34615969cf
|
||||
guid: 9a2c5f3c4d03d754fb5bf9318ab564f4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 308db146d763b534a920cb846a7af7eb
|
||||
guid: abb5812729435ce45946d5d1312dfbff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user