Update
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 287c0a05bd6431943a702d33fdb140fe
|
||||
folderAsset: yes
|
||||
timeCreated: 1544556369
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a61d8dd2057358449ba4a10812f65a3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37f223e0a67f76246b008bdad1aaaf02
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,104 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 115de49d5a92a5146ba0852ac80712a7
|
||||
ModelImporter:
|
||||
serializedVersion: 23
|
||||
fileIDToRecycleName:
|
||||
100000: //RootNode
|
||||
400000: //RootNode
|
||||
2100000: VBOT__main_torso1.001
|
||||
2100002: VBOT__secondary_torso1.001
|
||||
2100004: VBOT__Main_members1.001
|
||||
2100006: VBOT__Secondary_members1.001
|
||||
2100008: VBOT__metal3.001
|
||||
2100010: VBOT__metal4.001
|
||||
2100012: VBOT__rubber1.001
|
||||
2100014: No Name
|
||||
2300000: //RootNode
|
||||
3300000: //RootNode
|
||||
4300000: EntityPreview
|
||||
externalObjects: {}
|
||||
materials:
|
||||
importMaterials: 1
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
materialLocation: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
resampleCurves: 1
|
||||
optimizeGameObjects: 0
|
||||
motionNodeName:
|
||||
rigImportErrors:
|
||||
rigImportWarnings:
|
||||
animationImportErrors:
|
||||
animationImportWarnings:
|
||||
animationRetargetingWarnings:
|
||||
animationDoRetargetingWarnings: 0
|
||||
importAnimatedCustomProperties: 0
|
||||
importConstraints: 0
|
||||
animationCompression: 1
|
||||
animationRotationError: 0.5
|
||||
animationPositionError: 0.5
|
||||
animationScaleError: 0.5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
extraUserProperties: []
|
||||
clipAnimations: []
|
||||
isReadable: 1
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
useSRGBMaterialColor: 1
|
||||
importVisibility: 1
|
||||
importBlendShapes: 1
|
||||
importCameras: 1
|
||||
importLights: 1
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
optimizeMeshForGPU: 1
|
||||
keepQuads: 0
|
||||
weldVertices: 1
|
||||
preserveHierarchy: 0
|
||||
indexFormat: 0
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVPackMargin: 4
|
||||
useFileScale: 1
|
||||
previousCalculatedGlobalScale: 1
|
||||
hasPreviousCalculatedGlobalScale: 0
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 3
|
||||
normalCalculationMode: 4
|
||||
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||
blendShapeNormalImportMode: 1
|
||||
normalSmoothingSource: 0
|
||||
importAnimation: 1
|
||||
copyAvatar: 0
|
||||
humanDescription:
|
||||
serializedVersion: 2
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: 0.5
|
||||
foreArmTwist: 0.5
|
||||
upperLegTwist: 0.5
|
||||
legTwist: 0.5
|
||||
armStretch: 0.05
|
||||
legStretch: 0.05
|
||||
feetSpacing: 0
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 0
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
animationType: 0
|
||||
humanoidOversampling: 1
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,128 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: EntityPreview
|
||||
m_Shader: {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords:
|
||||
- ETC1_EXTERNAL_ALPHA
|
||||
- _ALPHABLEND_ON
|
||||
m_LightmapFlags: 0
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _AlphaTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _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}
|
||||
- _DetailTex:
|
||||
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: 2800000, guid: 65afb4cbeb47dc14ea879b97a296e19f, type: 3}
|
||||
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_Ints: []
|
||||
m_Floats:
|
||||
- PixelSnap: 0
|
||||
- _BlendOp: 0
|
||||
- _BumpScale: 1
|
||||
- _CameraFadingEnabled: 0
|
||||
- _CameraFarFadeDistance: 2
|
||||
- _CameraNearFadeDistance: 1
|
||||
- _ColorMask: 15
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DistortionBlend: 0.5
|
||||
- _DistortionEnabled: 0
|
||||
- _DistortionStrength: 1
|
||||
- _DistortionStrengthScaled: 0
|
||||
- _DstBlend: 1
|
||||
- _EmissionEnabled: 0
|
||||
- _EnableExternalAlpha: 0
|
||||
- _FlipbookMode: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 1
|
||||
- _LightingEnabled: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 4
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Shininess: 0.01
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SoftParticlesEnabled: 0
|
||||
- _SoftParticlesFarFadeDistance: 1
|
||||
- _SoftParticlesNearFadeDistance: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 5
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _Strength: 0.347
|
||||
- _UVSec: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 0
|
||||
m_Colors:
|
||||
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
|
||||
- _Color: {r: 1, g: 0.8260788, b: 0.08962262, a: 0.25}
|
||||
- _Emission: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _Flip: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _SpecColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _Specular: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _TintColor: {r: 1, g: 0.8260788, b: 0.08962262, a: 0.25}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b81f57418ba1a74194ccf6757901fbc
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,98 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cbea9d34df844f47a2214ce2a3072e0
|
||||
ModelImporter:
|
||||
serializedVersion: 23
|
||||
fileIDToRecycleName:
|
||||
100000: //RootNode
|
||||
400000: //RootNode
|
||||
2100000: Material
|
||||
2300000: //RootNode
|
||||
3300000: //RootNode
|
||||
4300000: Cube
|
||||
4300002: LocationPreview
|
||||
externalObjects: {}
|
||||
materials:
|
||||
importMaterials: 1
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
materialLocation: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
resampleCurves: 1
|
||||
optimizeGameObjects: 0
|
||||
motionNodeName:
|
||||
rigImportErrors:
|
||||
rigImportWarnings:
|
||||
animationImportErrors:
|
||||
animationImportWarnings:
|
||||
animationRetargetingWarnings:
|
||||
animationDoRetargetingWarnings: 0
|
||||
importAnimatedCustomProperties: 0
|
||||
importConstraints: 0
|
||||
animationCompression: 1
|
||||
animationRotationError: 0.5
|
||||
animationPositionError: 0.5
|
||||
animationScaleError: 0.5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
extraUserProperties: []
|
||||
clipAnimations: []
|
||||
isReadable: 1
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
useSRGBMaterialColor: 1
|
||||
importVisibility: 1
|
||||
importBlendShapes: 1
|
||||
importCameras: 1
|
||||
importLights: 1
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
optimizeMeshForGPU: 1
|
||||
keepQuads: 0
|
||||
weldVertices: 1
|
||||
preserveHierarchy: 0
|
||||
indexFormat: 0
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVPackMargin: 4
|
||||
useFileScale: 1
|
||||
previousCalculatedGlobalScale: 1
|
||||
hasPreviousCalculatedGlobalScale: 0
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 3
|
||||
normalCalculationMode: 4
|
||||
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||
blendShapeNormalImportMode: 1
|
||||
normalSmoothingSource: 0
|
||||
importAnimation: 1
|
||||
copyAvatar: 0
|
||||
humanDescription:
|
||||
serializedVersion: 2
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: 0.5
|
||||
foreArmTwist: 0.5
|
||||
upperLegTwist: 0.5
|
||||
legTwist: 0.5
|
||||
armStretch: 0.05
|
||||
legStretch: 0.05
|
||||
feetSpacing: 0
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 0
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
animationType: 0
|
||||
humanoidOversampling: 1
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,121 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
public partial class vMenuComponent
|
||||
{
|
||||
public const string path = "Invector/Utils/";
|
||||
|
||||
[MenuItem(path + "SimpleTrigger")]
|
||||
public static void AddSimpleTrigger()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.vSimpleTrigger>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "AnimatorEventReceiver")]
|
||||
public static void AddAnimatorEventReceiver()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.vEventSystems.vAnimatorEventReceiver>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "MessageReceiver")]
|
||||
public static void AddMessageReceiver()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.vMessageReceiver>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "MessageSender")]
|
||||
public static void AddMessageSender()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.vMessageSender>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "EventWithDelay")]
|
||||
public static void AddEventWithDelay()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.Utils.vEventWithDelay>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "DestroyGameObject")]
|
||||
public static void AddDestroyGameObject()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.vDestroyGameObject>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "DestroyOnTrigger")]
|
||||
public static void AddDestroyOnTrigger()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.vDestroyOnTrigger>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "PlayRandomClip")]
|
||||
public static void AddPlayRandomClip()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.vPlayRandomClip>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "RotateObject")]
|
||||
public static void AddRotateObject()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.vRotateObject>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "LookAtCamera")]
|
||||
public static void AddLookAtCamera()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.vLookAtCamera>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "Instantiate")]
|
||||
public static void AddInstantiate()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.Utils.vInstantiate>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "SetParent")]
|
||||
public static void AddSetParent()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.Utils.vSetParent>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "ResetTransform")]
|
||||
public static void AddResetTransform()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.Utils.vResetTransform>();
|
||||
}
|
||||
|
||||
[MenuItem(path + "DestroyChildrens")]
|
||||
public static void AddDestroyChildrens()
|
||||
{
|
||||
var currentObject = Selection.activeGameObject;
|
||||
if (currentObject)
|
||||
currentObject.AddComponent<Invector.Utils.vDestroyChildrens>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfad9801586f60944b29e51fbca43950
|
||||
timeCreated: 1544056336
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class vCheckForProjectSettings
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static bool isClosed;
|
||||
public static int checkLayer;
|
||||
public static GUIStyle style;
|
||||
|
||||
static vCheckForProjectSettings()
|
||||
{
|
||||
#if UNITY_2018
|
||||
SceneView.onSceneGUIDelegate -= OnScene;
|
||||
SceneView.onSceneGUIDelegate += OnScene;
|
||||
#elif UNITY_2019_1_OR_NEWER
|
||||
SceneView.duringSceneGui -= OnScene;
|
||||
SceneView.duringSceneGui += OnScene;
|
||||
|
||||
#endif
|
||||
}
|
||||
public static void OnScene(SceneView sceneView)
|
||||
{
|
||||
CheckLayer();
|
||||
}
|
||||
|
||||
static bool IsAxisAvailable(string axisName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Input.GetAxis(axisName);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckLayer()
|
||||
{
|
||||
Handles.BeginGUI();
|
||||
|
||||
checkLayer = LayerMask.NameToLayer("Player");
|
||||
var rect = new Rect();
|
||||
bool validation = Validation();
|
||||
var content = EditorGUIUtility.IconContent("console.warnicon.sml");
|
||||
GUILayout.Space(-20);
|
||||
content.tooltip = " INVECTOR WARNING!\nClick to open or close the message";
|
||||
if (validation && isClosed && GUILayout.Button(content, GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false)))
|
||||
{
|
||||
isClosed = !isClosed;
|
||||
}
|
||||
|
||||
if (validation && !isClosed)
|
||||
{
|
||||
if (style == null)
|
||||
{
|
||||
style = new GUIStyle(EditorStyles.whiteLabel);
|
||||
style.fontSize = 20;
|
||||
style.alignment = TextAnchor.MiddleCenter;
|
||||
style.fontStyle = FontStyle.Bold;
|
||||
style.wordWrap = true;
|
||||
style.clipping = TextClipping.Overflow;
|
||||
}
|
||||
rect.width = 400;
|
||||
rect.height = 200;
|
||||
string myString = "Missing ProjectSettings\nGo to the Menu Invector/Import ProjectSettings";
|
||||
GUILayout.BeginArea(rect);
|
||||
if (GUILayout.Button(content, EditorStyles.popup))
|
||||
{
|
||||
isClosed = true;
|
||||
}
|
||||
GUILayout.Box("", EditorStyles.textField, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
|
||||
rect = GUILayoutUtility.GetLastRect();
|
||||
GUI.Label(rect, myString, style);
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
Handles.EndGUI();
|
||||
}
|
||||
|
||||
private static bool Validation()
|
||||
{
|
||||
return checkLayer != 8 || !IsAxisAvailable("LeftAnalogHorizontal");
|
||||
}
|
||||
|
||||
public static void ResetMethod()
|
||||
{
|
||||
#if UNITY_2018
|
||||
SceneView.onSceneGUIDelegate += OnScene;
|
||||
#elif UNITY_2019_1_OR_NEWER
|
||||
SceneView.duringSceneGui += OnScene;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95de98cb992ef4546815b25d2a8e760e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,93 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.Utils
|
||||
{
|
||||
[CustomEditor(typeof(vComment))]
|
||||
public class vCommentEditor : UnityEditor.Editor
|
||||
{
|
||||
SerializedProperty inEdit;
|
||||
SerializedProperty comment;
|
||||
SerializedProperty header;
|
||||
GUIContent textContent, headerContent, editButtonContent;
|
||||
GUIStyle window, iconStyle, textStyle;
|
||||
GUISkin skin;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
inEdit = serializedObject.FindProperty("inEdit");
|
||||
comment = serializedObject.FindProperty("comment");
|
||||
header = serializedObject.FindProperty("header");
|
||||
skin = Resources.Load("vSkin") as GUISkin;
|
||||
textContent = new GUIContent();
|
||||
editButtonContent = new GUIContent("", Resources.Load("vCommentEditIcon") as Texture2D, "Enable or Disable Edit Mode");
|
||||
headerContent = new GUIContent(Resources.Load("icon_v2") as Texture2D);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
inEdit.boolValue = false; if (serializedObject != null && serializedObject.targetObject != null) serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
public override bool UseDefaultMargins()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
textStyle = new GUIStyle(EditorStyles.label);
|
||||
window = skin.GetStyle("vCommentWindow");
|
||||
iconStyle = skin.GetStyle("vCommentHeader");
|
||||
EditorGUILayout.BeginVertical(window);
|
||||
{
|
||||
GUILayout.Space(-(window.padding.top - 5));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
Color color = GUI.color;
|
||||
headerContent.text = header.stringValue;
|
||||
GUILayout.Box(headerContent, iconStyle, GUILayout.Height(30));
|
||||
GUILayout.Space(-10);
|
||||
if (GUILayout.Button(editButtonContent, GUIStyle.none, GUILayout.Width(30), GUILayout.Height(30)))
|
||||
{
|
||||
GenericMenu menu = new GenericMenu();
|
||||
menu.AddSeparator("");
|
||||
menu.AddItem(new GUIContent(!inEdit.boolValue ? "Edit Comment" : "Exit Edit"), false, () => { inEdit.boolValue = !inEdit.boolValue; serializedObject.ApplyModifiedProperties(); });
|
||||
menu.AddSeparator("");
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space((window.padding.top));
|
||||
|
||||
if (inEdit.boolValue)
|
||||
{
|
||||
EditorGUILayout.HelpBox("You can use RichText to customize your comment and header", MessageType.Info);
|
||||
GUILayout.Label("Header", EditorStyles.centeredGreyMiniLabel);
|
||||
header.stringValue = GUILayout.TextField(header.stringValue, 50);
|
||||
GUILayout.Label("Comment", EditorStyles.boldLabel);
|
||||
EditorGUILayout.PropertyField(comment, GUIContent.none);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (textContent != null && textStyle != null)
|
||||
{
|
||||
textStyle.richText = true;
|
||||
textStyle.normal.background = null;
|
||||
textStyle.wordWrap = true;
|
||||
textStyle.font = window.font;
|
||||
textStyle.fontStyle = window.fontStyle;
|
||||
textStyle.fontSize = window.fontSize;
|
||||
textStyle.alignment = window.alignment;
|
||||
GUILayout.Box(comment.stringValue, textStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3fcd47da60e70c4c93314b7d5fcb298
|
||||
timeCreated: 1557867630
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
namespace Invector.Utils
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(vSelectableStringAttribute))]
|
||||
public class vSelectableStringDrawer : DecoratorDrawer
|
||||
{
|
||||
GUIStyle _selectableAreaStyle;
|
||||
public GUIStyle SelectableAreaStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_selectableAreaStyle==null)
|
||||
{
|
||||
_selectableAreaStyle = new GUIStyle(EditorStyles.textArea);
|
||||
}
|
||||
return _selectableAreaStyle;
|
||||
}
|
||||
|
||||
}
|
||||
vSelectableStringAttribute selectableString
|
||||
{
|
||||
get { return ((vSelectableStringAttribute)attribute); }
|
||||
}
|
||||
|
||||
public override float GetHeight()
|
||||
{
|
||||
float height = SelectableAreaStyle.CalcSize(new GUIContent(selectableString.selectableText)).y;
|
||||
return height + EditorGUIUtility.singleLineHeight+8;
|
||||
}
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
var rect = position;
|
||||
rect.height = EditorGUIUtility.singleLineHeight;
|
||||
GUI.Label(rect, selectableString.tittle);
|
||||
var textArea = rect;
|
||||
textArea.y += rect.height+5;
|
||||
textArea.height = (position.height - rect.height)-10;
|
||||
GUI.TextArea(textArea, selectableString.selectableText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6ce58a22b98ee447a609bababec06da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,82 @@
|
||||
using Invector;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class PlaySoundLoop : MonoBehaviour
|
||||
{
|
||||
public AudioClip[] clips;
|
||||
public bool playOnAwake;
|
||||
public AnimationCurve volumeCurve;
|
||||
public AnimationCurve pitchCurve;
|
||||
public AnimationCurve frequencyCurve;
|
||||
protected AudioSource source;
|
||||
[vReadOnly]
|
||||
public float currentCurveTime;
|
||||
bool isPlaying;
|
||||
|
||||
public void ChangeCurveTime(float curveTime)
|
||||
{
|
||||
currentCurveTime = curveTime;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
source = GetComponent<AudioSource>();
|
||||
if (source != null && playOnAwake) { Play(); }
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
isPlaying = true;
|
||||
StopAllCoroutines();
|
||||
if (gameObject.activeInHierarchy)
|
||||
{
|
||||
currentCurveTime = 0;
|
||||
StartCoroutine(PlayRoutine());
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
isPlaying = false;
|
||||
}
|
||||
|
||||
IEnumerator PlayRoutine()
|
||||
{
|
||||
float time = 0;
|
||||
while (isPlaying)
|
||||
{
|
||||
float _frequency = frequencyCurve.Evaluate(currentCurveTime);
|
||||
if (time < _frequency)
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
time = 0;
|
||||
PlayOnShot();
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void PlayOnShot()
|
||||
{
|
||||
if (source)
|
||||
{
|
||||
float _frequency = frequencyCurve.Evaluate(currentCurveTime);
|
||||
float _volume = volumeCurve.Evaluate(currentCurveTime);
|
||||
float _pitch = pitchCurve.Evaluate(currentCurveTime);
|
||||
|
||||
AudioClip clip = clips[Random.Range(0, clips.Length)];
|
||||
if (clip != null)
|
||||
{
|
||||
source.volume = _volume;
|
||||
source.pitch = _pitch;
|
||||
source.PlayOneShot(clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 914be654c1d00384fa4ce6113356125d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,103 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
namespace Invector.Utils
|
||||
{
|
||||
[RequireComponent(typeof(UnityEngine.UI.Slider))]
|
||||
[RequireComponent(typeof(CanvasGroup))]
|
||||
[vClassHeader("ShowHideSlideControl", false)]
|
||||
public class ShowHideSlideControl : vMonoBehaviour
|
||||
{
|
||||
public UnityEngine.UI.Slider slider;
|
||||
public UnityEngine.CanvasGroup canvasGroup;
|
||||
public float fadeIn = 1, fadeOut = 1;
|
||||
|
||||
public UnityEngine.Events.UnityEvent onStartFadeIn, onStartFadeOut, onFinishFadeIn, onFinishFadeOut;
|
||||
Coroutine currentRoutine;
|
||||
// Start is called before the first frame update
|
||||
|
||||
|
||||
float slideValue => (float)System.Math.Round(slider.value, 1);
|
||||
void Start()
|
||||
{
|
||||
if (slider == null) slider = GetComponent<UnityEngine.UI.Slider>();
|
||||
if (canvasGroup == null) canvasGroup = GetComponent<UnityEngine.CanvasGroup>();
|
||||
if (slider != null)
|
||||
{
|
||||
slider.onValueChanged.AddListener(OnChangeSlideValue);
|
||||
|
||||
CheckValue();
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckValue()
|
||||
{
|
||||
if (slideValue >= slider.maxValue)
|
||||
{
|
||||
HideBar();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowBar();
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowBar()
|
||||
{
|
||||
if (inFadeIn || canvasGroup.alpha >= 1) return;
|
||||
inFadeIn = false;
|
||||
inFadeOut = false;
|
||||
if (currentRoutine != null) StopCoroutine(currentRoutine);
|
||||
currentRoutine = StartCoroutine(ControllBarAlphaRoutine());
|
||||
}
|
||||
public void HideBar()
|
||||
{
|
||||
if (inFadeOut || canvasGroup.alpha <= 0) return;
|
||||
inFadeIn = false;
|
||||
inFadeOut = false;
|
||||
if (currentRoutine != null) StopCoroutine(currentRoutine);
|
||||
currentRoutine = StartCoroutine(ControllBarAlphaRoutine(false));
|
||||
}
|
||||
|
||||
|
||||
bool inFadeIn, inFadeOut;
|
||||
|
||||
|
||||
|
||||
IEnumerator ControllBarAlphaRoutine(bool show = true)
|
||||
{
|
||||
float value = canvasGroup.alpha;
|
||||
|
||||
if (show)
|
||||
{
|
||||
inFadeIn = true;
|
||||
onStartFadeIn.Invoke();
|
||||
while (canvasGroup.alpha < 1f)
|
||||
{
|
||||
canvasGroup.alpha += Time.deltaTime * fadeIn;
|
||||
yield return null;
|
||||
}
|
||||
canvasGroup.alpha = 1;
|
||||
inFadeIn = false;
|
||||
onFinishFadeIn.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
inFadeOut = true;
|
||||
onStartFadeOut.Invoke();
|
||||
while (canvasGroup.alpha > 0f)
|
||||
{
|
||||
canvasGroup.alpha -= Time.deltaTime * fadeOut;
|
||||
yield return null;
|
||||
}
|
||||
canvasGroup.alpha = 0;
|
||||
inFadeOut = false;
|
||||
onFinishFadeOut.Invoke();
|
||||
}
|
||||
currentRoutine = null;
|
||||
}
|
||||
private void OnChangeSlideValue(float arg0)
|
||||
{
|
||||
CheckValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad76def59c22bc84aafbb771221b822d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,74 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
public static class vCharacterExtensions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Load all <see cref="vCharacterController.vActions.IActionController"/> and derivatives in character gameObject to register to events <see cref="vCharacterController.vCharacter.onActionEnter"/>,<see cref="vCharacterController.vCharacter.onActionStay"/> and <see cref="vCharacterController.vCharacter.onActionExit"/>.
|
||||
/// </summary>
|
||||
/// <param name="character">Target <seealso cref="vCharacterController.vCharacter>"/></param>
|
||||
public static void LoadActionControllers(this vCharacterController.vCharacter character, bool debug = false)
|
||||
{
|
||||
var actionControllers = character.GetComponentsInChildren<vCharacterController.vActions.IActionController>();
|
||||
for (int i = 0; i < actionControllers.Length; i++)
|
||||
{
|
||||
if (actionControllers[i].enabled)
|
||||
{
|
||||
if (actionControllers[i] is vCharacterController.vActions.IActionListener)
|
||||
{
|
||||
var actionListener = actionControllers[i] as vCharacterController.vActions.IActionListener;
|
||||
|
||||
{
|
||||
if (actionListener.actionEnter)
|
||||
{
|
||||
character.onActionEnter.RemoveListener(actionListener.OnActionEnter);
|
||||
character.onActionEnter.AddListener(actionListener.OnActionEnter);
|
||||
if (debug) Debug.Log("Register Action Enter event to the " + actionListener.GetType().Name);
|
||||
}
|
||||
|
||||
if (actionListener.actionStay)
|
||||
{
|
||||
character.onActionStay.RemoveListener(actionListener.OnActionStay);
|
||||
character.onActionStay.AddListener(actionListener.OnActionStay);
|
||||
if (debug) Debug.Log("Register Action Stay event to the " + actionListener.GetType().Name);
|
||||
}
|
||||
|
||||
if (actionListener.actionExit)
|
||||
{
|
||||
character.onActionExit.RemoveListener(actionListener.OnActionExit);
|
||||
character.onActionExit.AddListener(actionListener.OnActionExit);
|
||||
if (debug) Debug.Log("Register action Exit event to the " + actionListener.GetType().Name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (actionControllers[i] is vCharacterController.vActions.IActionEnterListener)
|
||||
{
|
||||
character.onActionEnter.RemoveListener((actionControllers[i] as vCharacterController.vActions.IActionEnterListener).OnActionEnter);
|
||||
character.onActionEnter.AddListener((actionControllers[i] as vCharacterController.vActions.IActionEnterListener).OnActionEnter);
|
||||
if (debug) Debug.Log("Register Action Enter event to the " + actionControllers[i].GetType().Name);
|
||||
}
|
||||
|
||||
if (actionControllers[i] is vCharacterController.vActions.IActionStayListener)
|
||||
{
|
||||
character.onActionStay.RemoveListener((actionControllers[i] as vCharacterController.vActions.IActionStayListener).OnActionStay);
|
||||
character.onActionStay.AddListener((actionControllers[i] as vCharacterController.vActions.IActionStayListener).OnActionStay);
|
||||
if (debug) Debug.Log("Register Action Stay event to the " + actionControllers[i].GetType().Name);
|
||||
}
|
||||
|
||||
if (actionControllers[i] is vCharacterController.vActions.IActionExitListener)
|
||||
{
|
||||
character.onActionExit.RemoveListener((actionControllers[i] as vCharacterController.vActions.IActionExitListener).OnActionExit);
|
||||
character.onActionExit.AddListener((actionControllers[i] as vCharacterController.vActions.IActionExitListener).OnActionExit);
|
||||
if (debug) Debug.Log("Register Action Exit event to the " + actionControllers[i].GetType().Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9101f12c6b56834abc30a6adfae8705
|
||||
timeCreated: 1556917721
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.Utils
|
||||
{
|
||||
public class vComment : MonoBehaviour
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[SerializeField] protected string header = "COMMENT";
|
||||
[Multiline]
|
||||
[SerializeField] protected string comment;
|
||||
|
||||
[SerializeField] protected bool inEdit;
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19c789670a80b704eba4dfebed94a111
|
||||
timeCreated: 1476921840
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,118 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class vDebugUtils : MonoBehaviour
|
||||
{
|
||||
public KeyCode timeScaleDown = KeyCode.KeypadMinus, timeScaleUp = KeyCode.KeypadPlus;
|
||||
public float timeScaleChangeValue = 0.1f;
|
||||
public bool affectFixedDeltaTime = true;
|
||||
|
||||
float currentFixedDeltaTime;
|
||||
List<DebugMessage> debugMessages = new List<DebugMessage>();
|
||||
public float displayMessageTime = 5f;
|
||||
enum MessageType
|
||||
{
|
||||
Normal, Warning, Error
|
||||
}
|
||||
class DebugMessage
|
||||
{
|
||||
public string message;
|
||||
public float startTime;
|
||||
public float duration;
|
||||
public string timeString;
|
||||
public MessageType messageType;
|
||||
public DebugMessage(string message, float startTime, float duration, MessageType messageType)
|
||||
{
|
||||
this.message = message;
|
||||
this.startTime = startTime;
|
||||
this.messageType = messageType;
|
||||
this.duration = duration;
|
||||
timeString = System.DateTime.Now.ToString(@"HH\:mm\:ss");
|
||||
}
|
||||
public bool isAlive => startTime + duration > Time.time;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
currentFixedDeltaTime = Time.fixedDeltaTime;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(timeScaleDown))
|
||||
{
|
||||
Time.timeScale = Mathf.Clamp(Time.timeScale - timeScaleChangeValue, 0, 1f);
|
||||
if (affectFixedDeltaTime)
|
||||
{
|
||||
Time.fixedDeltaTime = Time.timeScale * currentFixedDeltaTime;
|
||||
}
|
||||
}
|
||||
else if (Input.GetKeyDown(timeScaleUp))
|
||||
{
|
||||
Time.timeScale = Mathf.Clamp(Time.timeScale + timeScaleChangeValue, 0, 1f);
|
||||
if (affectFixedDeltaTime)
|
||||
{
|
||||
Time.fixedDeltaTime = Time.timeScale * currentFixedDeltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PrintMessage(string message)
|
||||
{
|
||||
Debug.Log(message);
|
||||
debugMessages.Add(new DebugMessage(message, Time.time, displayMessageTime, MessageType.Normal));
|
||||
scrool.y = lastRectPosition;
|
||||
}
|
||||
public void PrintMessageWarning(string message)
|
||||
{
|
||||
Debug.LogWarning(message);
|
||||
debugMessages.Add(new DebugMessage(message, Time.time, displayMessageTime, MessageType.Warning));
|
||||
scrool.y = lastRectPosition;
|
||||
}
|
||||
public void PrintMessageError(string message)
|
||||
{
|
||||
Debug.LogError(message);
|
||||
debugMessages.Add(new DebugMessage(message, Time.time, displayMessageTime, MessageType.Error));
|
||||
scrool.y = lastRectPosition;
|
||||
}
|
||||
|
||||
Vector2 scrool;
|
||||
GUIStyle messageStyle;
|
||||
float lastRectPosition;
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Label($"TimeScale:{Time.timeScale.ToString()}");
|
||||
|
||||
if (debugMessages.Count > 0)
|
||||
{
|
||||
if (messageStyle == null)
|
||||
{
|
||||
messageStyle = new GUIStyle(GUI.skin.box);
|
||||
messageStyle.wordWrap = true;
|
||||
messageStyle.alignment = TextAnchor.MiddleLeft;
|
||||
messageStyle.fontSize = 10;
|
||||
}
|
||||
scrool = GUILayout.BeginScrollView(scrool, "box", GUILayout.MinHeight(100), GUILayout.Width(Screen.width * 0.2f), GUILayout.MaxHeight(Screen.height * 0.8f));
|
||||
for (int i = 0; i < debugMessages.Count; i++)
|
||||
{
|
||||
var m = debugMessages[i];
|
||||
if (m.isAlive)
|
||||
{
|
||||
var t = m.messageType;
|
||||
|
||||
|
||||
|
||||
GUI.color = t == MessageType.Warning ? Color.yellow : t == MessageType.Error ? Color.red : Color.white;
|
||||
|
||||
GUILayout.Label(string.Format("[{0}] : {1}", m.timeString, m.message), messageStyle);
|
||||
lastRectPosition = GUILayoutUtility.GetLastRect().y;
|
||||
}
|
||||
else
|
||||
{
|
||||
debugMessages.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62e8d8177eef7234486c733c7e983542
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
namespace Invector.Utils
|
||||
{
|
||||
public class vDestroyChildrens : MonoBehaviour
|
||||
{
|
||||
|
||||
public virtual void DestroyChildrens()
|
||||
{
|
||||
DestroyChildrens(transform);
|
||||
}
|
||||
public virtual void DestroyChildrensOfOther(Transform target)
|
||||
{
|
||||
DestroyChildrens(target);
|
||||
}
|
||||
protected virtual void DestroyChildrens(Transform target)
|
||||
{
|
||||
int childs = target.childCount;
|
||||
for (int i = childs - 1; i >= 0; i--)
|
||||
{
|
||||
Destroy(target.GetChild(i).gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66b86cb6ba025dc419d88877e44fa32f
|
||||
timeCreated: 1547865129
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[vClassHeader("Destroy GameObject", openClose = false)]
|
||||
public class vDestroyGameObject : vMonoBehaviour
|
||||
{
|
||||
public float delay;
|
||||
public UnityEngine.Events.UnityEvent onDestroy;
|
||||
IEnumerator Start()
|
||||
{
|
||||
yield return new WaitForSeconds(delay);
|
||||
onDestroy.Invoke();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cd39039863a63e48ad1e9260ed01bc8
|
||||
timeCreated: 1461789193
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using Invector.vCharacterController;
|
||||
public class vEnableDisableByInputDevice : MonoBehaviour
|
||||
{
|
||||
public InputDevice inputDevice;
|
||||
public CheckMethod methodToCheck;
|
||||
public enum CheckMethod
|
||||
{
|
||||
Equals,
|
||||
Different,
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
vInput.instance.onChangeInputType -= OnChangeInput;
|
||||
vInput.instance.onChangeInputType += OnChangeInput;
|
||||
OnChangeInput(vInput.instance.inputDevice);
|
||||
}
|
||||
|
||||
public void OnChangeInput(InputDevice type)
|
||||
{
|
||||
bool validate = methodToCheck == CheckMethod.Different ? type != inputDevice : type == inputDevice;
|
||||
if (gameObject.activeSelf != validate) gameObject.SetActive(validate);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efdfb32cfcae535408a39c060b2b1a40
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class vEnableDisableEvent : MonoBehaviour
|
||||
{
|
||||
public UnityEngine.Events.UnityEvent onEnable, onDisable;
|
||||
private void OnEnable()
|
||||
{
|
||||
onEnable.Invoke();
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
onDisable.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e9b25d56c268e14c84bf89b83bdd082
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class vEnableRandomObject : MonoBehaviour
|
||||
{
|
||||
public GameObject[] objects;
|
||||
public bool enableOnStart;
|
||||
|
||||
System.Random random;
|
||||
// Start is called before the first frame update
|
||||
protected void Awake()
|
||||
{
|
||||
random = new System.Random(this.GetInstanceID());
|
||||
if (enableOnStart)
|
||||
EnableObject();
|
||||
}
|
||||
|
||||
public virtual void EnableObject()
|
||||
{
|
||||
int indexToEnable = random.Next(0, objects.Length);
|
||||
for (int i = 0; i < objects.Length; i++)
|
||||
{
|
||||
objects[i].SetActive(i == indexToEnable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e09df8b422606084dae73442cdaacbb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
|
||||
using UnityEngine;
|
||||
namespace Invector.Utils
|
||||
{
|
||||
[vClassHeader("Entity Preview")]
|
||||
public sealed class vEntityPreview : vMonoBehaviour
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public Color previewColor = new Color(1, 1, 1, 0.25f);
|
||||
public bool drawBase = true;
|
||||
[ vHideInInspector("drawBase")] public float baseRadius = 1;
|
||||
public bool useCustomMesh;
|
||||
[vHideInInspector("useCustomMesh")] public Mesh previewMesh;
|
||||
public bool showInPlayMode;
|
||||
#region Static
|
||||
static Mesh defaultPreviewMesh;
|
||||
static Material defaultPreviewMaterial;
|
||||
static Mesh sphereBaseMesh;
|
||||
static void LoadDefaultMaterial()
|
||||
{
|
||||
if (!defaultPreviewMaterial)
|
||||
{
|
||||
var defaultMat = (Material)Resources.Load("EntityPreview/EntityPreview", typeof(Material));
|
||||
defaultPreviewMaterial = defaultMat;
|
||||
}
|
||||
}
|
||||
static void LoadDefaultMesh()
|
||||
{
|
||||
|
||||
if (!defaultPreviewMesh)
|
||||
{
|
||||
var defaultMesh = (Mesh)Resources.Load("EntityPreview/EntityPreview", typeof(Mesh));
|
||||
defaultPreviewMesh = defaultMesh;
|
||||
}
|
||||
}
|
||||
static void LoadSphereBase()
|
||||
{
|
||||
if (!sphereBaseMesh)
|
||||
{
|
||||
var go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
|
||||
sphereBaseMesh = go.GetComponent<MeshFilter>().sharedMesh;
|
||||
DestroyImmediate(go);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
void OnDrawGizmos()
|
||||
{
|
||||
if (Application.isPlaying && !showInPlayMode) return;
|
||||
|
||||
if (!useCustomMesh)
|
||||
{
|
||||
LoadDefaultMesh();
|
||||
if(previewMesh!=defaultPreviewMesh) previewMesh = defaultPreviewMesh;
|
||||
}
|
||||
if (previewMesh)
|
||||
{
|
||||
if (defaultPreviewMaterial)
|
||||
{
|
||||
Gizmos.color = Color.clear;
|
||||
Gizmos.DrawCube(transform.position + Vector3.up * 1, new Vector3(1, 2, 1));
|
||||
if (drawBase)
|
||||
{
|
||||
if (sphereBaseMesh)
|
||||
{
|
||||
Matrix4x4 cubeTransform = Matrix4x4.TRS(transform.position + Vector3.up * 0.01f, transform.rotation, new Vector3(1, 0.0f, 1) * (baseRadius));
|
||||
defaultPreviewMaterial.color = previewColor;
|
||||
defaultPreviewMaterial.SetColor("_TintColor", previewColor);
|
||||
for (int pass = 0; pass < defaultPreviewMaterial.passCount; pass++)
|
||||
{
|
||||
if (defaultPreviewMaterial.SetPass(pass))
|
||||
{
|
||||
Graphics.DrawMeshNow(sphereBaseMesh, cubeTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadSphereBase();
|
||||
}
|
||||
}
|
||||
defaultPreviewMaterial.color = previewColor;
|
||||
defaultPreviewMaterial.SetColor("_TintColor", previewColor);
|
||||
|
||||
for (int pass = 0; pass < defaultPreviewMaterial.passCount; pass++)
|
||||
{
|
||||
|
||||
if (defaultPreviewMaterial.SetPass(pass))
|
||||
{
|
||||
Graphics.DrawMeshNow(previewMesh, transform.localToWorldMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
Gizmos.color = Color.white;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadDefaultMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad63bcafabe53104c838faae1bdabd3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,76 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.Utils
|
||||
{
|
||||
[vClassHeader("Events With Delay")]
|
||||
public class vEventWithDelay : vMonoBehaviour
|
||||
{
|
||||
public bool triggerOnStart;
|
||||
public bool triggerOnEnable;
|
||||
|
||||
[vHideInInspector("triggerOnStart")]
|
||||
public bool all;
|
||||
[vHideInInspector("triggerOnStart")]
|
||||
public int eventIndex;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!this.enabled) return;
|
||||
|
||||
if (triggerOnEnable)
|
||||
{
|
||||
if (all) DoEvents();
|
||||
else DoEvent(eventIndex);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
if (triggerOnStart)
|
||||
{
|
||||
if (all) DoEvents();
|
||||
else DoEvent(eventIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
}
|
||||
[SerializeField] private vEventWithDelayObject[] events = new vEventWithDelayObject[0];
|
||||
public virtual void DoEvents()
|
||||
{
|
||||
if (!this.enabled) return;
|
||||
for (int i = 0; i < events.Length; i++)
|
||||
StartCoroutine(DoEventWithDelay(events[i]));
|
||||
}
|
||||
|
||||
public virtual void DoEvent(int index)
|
||||
{
|
||||
if (!this.enabled) return;
|
||||
if (index < events.Length && events.Length > 0) StartCoroutine(DoEventWithDelay(events[index]));
|
||||
}
|
||||
|
||||
public virtual void DoEvent(string name)
|
||||
{
|
||||
if (!this.enabled) return;
|
||||
vEventWithDelayObject _e = System.Array.Find(events, e => e.name.Equals(name));
|
||||
if (_e != null) StartCoroutine(DoEventWithDelay(_e));
|
||||
}
|
||||
|
||||
IEnumerator DoEventWithDelay(vEventWithDelayObject _event)
|
||||
{
|
||||
yield return new WaitForSeconds(_event.delay);
|
||||
_event.onDoEvent.Invoke();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class vEventWithDelayObject
|
||||
{
|
||||
public string name = "EventName";
|
||||
public float delay;
|
||||
public UnityEngine.Events.UnityEvent onDoEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f39d3c6f54abe74eb907d2a62776841
|
||||
timeCreated: 1525377554
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,526 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
public enum vAngleAxis
|
||||
{
|
||||
X, Y, Z
|
||||
}
|
||||
public static class vExtensions
|
||||
{
|
||||
public static void DebugPoint(this Vector3 vector, Color color, float time, float size = 0.25f)
|
||||
{
|
||||
Debug.DrawRay(vector, Vector3.right * size, color, time);
|
||||
Debug.DrawRay(vector, Vector3.left * size, color, time);
|
||||
Debug.DrawRay(vector, Vector3.forward * size, color, time);
|
||||
Debug.DrawRay(vector, Vector3.back * size, color, time);
|
||||
Debug.DrawRay(vector, Vector3.up * size, color, time);
|
||||
Debug.DrawRay(vector, Vector3.down * size, color, time);
|
||||
}
|
||||
public static void DebugPoint(this Vector3 vector, Color color, float size = 0.25f)
|
||||
{
|
||||
Debug.DrawRay(vector, Vector3.right * size, color);
|
||||
Debug.DrawRay(vector, Vector3.left * size, color);
|
||||
Debug.DrawRay(vector, Vector3.forward * size, color);
|
||||
Debug.DrawRay(vector, Vector3.back * size, color);
|
||||
Debug.DrawRay(vector, Vector3.up * size, color);
|
||||
Debug.DrawRay(vector, Vector3.down * size, color);
|
||||
}
|
||||
public static string InsertSpaceBeforeUpperCase(this string input)
|
||||
{
|
||||
var result = "";
|
||||
foreach (char c in input)
|
||||
{
|
||||
if (char.IsUpper(c))
|
||||
{
|
||||
// if not the first letter, insert space before uppercase
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
result += " ";
|
||||
}
|
||||
}
|
||||
// start new word
|
||||
result += c;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string RemoveUnderline(this string input)
|
||||
{
|
||||
return input.Replace("_", "");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear string spaces and turn to Upper
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToClearUpper(this string target)
|
||||
{
|
||||
return target.Replace(" ", string.Empty).ToUpper();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if Value is inside a range (greater equals min && less equals than Max)
|
||||
/// </summary>
|
||||
/// <param name="value">value to compare</param>
|
||||
/// <param name="min">min range</param>
|
||||
/// <param name="max">max range</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsInSideRange(this float value, float min, float max)
|
||||
{
|
||||
return value >= min && value <= max;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if Value is inside a range (greater equals min && less equals than Max)
|
||||
/// </summary>
|
||||
/// <param name="value">value to compare</param>
|
||||
/// <param name="minMaxRange">range (x min,y max)</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsInSideRange(this float value, Vector2 minMaxRange)
|
||||
{
|
||||
return value >= minMaxRange.x && value <= minMaxRange.y;
|
||||
}
|
||||
|
||||
public static bool IsVectorNaN(this Vector3 vector)
|
||||
{
|
||||
return float.IsNaN(vector.x) || float.IsNaN(vector.y) || float.IsNaN(vector.z);
|
||||
}
|
||||
|
||||
public static Vector3[] MakeSmoothCurve(this Vector3[] pts, float smoothFactor = 0.25f)
|
||||
{
|
||||
smoothFactor = Mathf.Clamp(smoothFactor, 0.1f, 0.9f);
|
||||
Vector3[] newPts = new Vector3[(pts.Length - 2) * 2 + 2];
|
||||
try
|
||||
{
|
||||
newPts[0] = pts[0];
|
||||
newPts[newPts.Length - 1] = pts[pts.Length - 1];
|
||||
|
||||
int j = 1;
|
||||
for (int i = 0; i < pts.Length - 2; i++)
|
||||
{
|
||||
newPts[j] = pts[i] + (pts[i + 1] - pts[i]) * (1f - smoothFactor);
|
||||
newPts[j + 1] = pts[i + 1] + (pts[i + 2] - pts[i + 1]) * smoothFactor;
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
newPts = pts;
|
||||
}
|
||||
return newPts;
|
||||
}
|
||||
|
||||
public static float GetLenght(this UnityEngine.AI.NavMeshPath path)
|
||||
{
|
||||
float lenght = 0;
|
||||
if (path != null && path.corners.Length > 1)
|
||||
{
|
||||
Vector3 lastPoint = path.corners[0];
|
||||
for (int i = 1; i < path.corners.Length; i++)
|
||||
{
|
||||
lenght += Vector3.Distance(lastPoint, path.corners[i]);
|
||||
lastPoint = path.corners[i];
|
||||
}
|
||||
}
|
||||
return lenght;
|
||||
}
|
||||
|
||||
public static List<Vector3> MakeSmoothCurve(this List<Vector3> pts, float smoothFactor = 0.25f)
|
||||
{
|
||||
smoothFactor = Mathf.Clamp(smoothFactor, 0.1f, 0.9f);
|
||||
List<Vector3> newPts = new List<Vector3>((pts.Count - 2) * 2 + 2);
|
||||
try
|
||||
{
|
||||
|
||||
newPts[0] = pts[0];
|
||||
newPts[newPts.Count - 1] = pts[pts.Count - 1];
|
||||
|
||||
int j = 1;
|
||||
for (int i = 0; i < pts.Count - 2; i++)
|
||||
{
|
||||
newPts[j] = pts[i] + (pts[i + 1] - pts[i]) * (1f - smoothFactor);
|
||||
newPts[j + 1] = pts[i + 1] + (pts[i + 2] - pts[i + 1]) * smoothFactor;
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
newPts = pts;
|
||||
}
|
||||
return newPts;
|
||||
}
|
||||
|
||||
public static Vector3[] MakeSmoothCurveArray(this List<Vector3> pts, float smoothFactor = 0.25f)
|
||||
{
|
||||
smoothFactor = Mathf.Clamp(smoothFactor, 0.1f, 0.9f);
|
||||
Vector3[] newPts = new Vector3[(pts.Count - 2) * 2 + 2];
|
||||
try
|
||||
{
|
||||
|
||||
newPts[0] = pts[0];
|
||||
newPts[newPts.Length - 1] = pts[pts.Count - 1];
|
||||
|
||||
int j = 1;
|
||||
for (int i = 0; i < pts.Count - 2; i++)
|
||||
{
|
||||
newPts[j] = pts[i] + (pts[i + 1] - pts[i]) * (1f - smoothFactor);
|
||||
newPts[j + 1] = pts[i + 1] + (pts[i + 2] - pts[i + 1]) * smoothFactor;
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
newPts = pts.vToArray();
|
||||
}
|
||||
return newPts;
|
||||
}
|
||||
|
||||
public static void SetLayerRecursively(this GameObject obj, int layer)
|
||||
{
|
||||
obj.layer = layer;
|
||||
|
||||
foreach (Transform child in obj.transform)
|
||||
{
|
||||
child.gameObject.SetLayerRecursively(layer);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ContainsLayer(this LayerMask layermask, int layer)
|
||||
{
|
||||
return layermask == (layermask | (1 << layer));
|
||||
}
|
||||
|
||||
public static void SetActiveChildren(this GameObject gameObjet, bool value)
|
||||
{
|
||||
foreach (Transform child in gameObjet.transform)
|
||||
{
|
||||
child.gameObject.SetActive(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if Transfom is children
|
||||
/// </summary>
|
||||
/// <param name="me"></param>
|
||||
/// <param name="target"></param>
|
||||
/// <returns></returns>
|
||||
public static bool isChild(this Transform me, Transform target)
|
||||
{
|
||||
if (!target)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var objName = target.gameObject.name;
|
||||
var obj = me.FindChildByNameRecursive(objName);
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return obj.Equals(target);
|
||||
}
|
||||
}
|
||||
|
||||
static Transform FindChildByNameRecursive(this Transform me, string name)
|
||||
{
|
||||
if (me.name == name)
|
||||
{
|
||||
return me;
|
||||
}
|
||||
|
||||
for (int i = 0; i < me.childCount; i++)
|
||||
{
|
||||
var child = me.GetChild(i);
|
||||
var found = child.FindChildByNameRecursive(name);
|
||||
if (found != null)
|
||||
{
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Normalized the angle. between -180 and 180 degrees
|
||||
/// </summary>
|
||||
/// <param Name="eulerAngle">Euler angle.</param>
|
||||
public static Vector3 NormalizeAngle(this Vector3 eulerAngle)
|
||||
{
|
||||
var delta = eulerAngle;
|
||||
|
||||
if (delta.x > 180)
|
||||
{
|
||||
delta.x -= 360;
|
||||
}
|
||||
else if (delta.x < -180)
|
||||
{
|
||||
delta.x += 360;
|
||||
}
|
||||
|
||||
if (delta.y > 180)
|
||||
{
|
||||
delta.y -= 360;
|
||||
}
|
||||
else if (delta.y < -180)
|
||||
{
|
||||
delta.y += 360;
|
||||
}
|
||||
|
||||
if (delta.z > 180)
|
||||
{
|
||||
delta.z -= 360;
|
||||
}
|
||||
else if (delta.z < -180)
|
||||
{
|
||||
delta.z += 360;
|
||||
}
|
||||
|
||||
return new Vector3(delta.x, delta.y, delta.z);//round values to angle;
|
||||
}
|
||||
|
||||
public static Vector3 Difference(this Vector3 vector, Vector3 otherVector)
|
||||
{
|
||||
return otherVector - vector;
|
||||
}
|
||||
|
||||
public static Vector3 AngleFormOtherDirection(this Vector3 directionA, Vector3 directionB)
|
||||
{
|
||||
if (directionA.normalized.magnitude == 0 || directionB.normalized.magnitude == 0) return Vector3.zero;
|
||||
return Quaternion.LookRotation(directionA).eulerAngles.AngleFormOtherEuler(Quaternion.LookRotation(directionB).eulerAngles);
|
||||
}
|
||||
|
||||
public static Vector3 AngleFormOtherDirection(this Vector3 directionA, Vector3 directionB, Vector3 up)
|
||||
{
|
||||
return Quaternion.LookRotation(directionA, up).eulerAngles.AngleFormOtherEuler(Quaternion.LookRotation(directionB, up).eulerAngles);
|
||||
}
|
||||
|
||||
public static Vector3 AngleFormOtherEuler(this Vector3 eulerA, Vector3 eulerB)
|
||||
{
|
||||
Vector3 angles = eulerA.NormalizeAngle().Difference(eulerB.NormalizeAngle()).NormalizeAngle();
|
||||
return angles;
|
||||
}
|
||||
|
||||
public static string ToStringColor(this bool value)
|
||||
{
|
||||
if (value) return "<color=green>YES</color>";
|
||||
else return "<color=red>NO</color>";
|
||||
}
|
||||
|
||||
public static float ClampAngle(float angle, float min, float max)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (angle < -360)
|
||||
{
|
||||
angle += 360;
|
||||
}
|
||||
|
||||
if (angle > 360)
|
||||
{
|
||||
angle -= 360;
|
||||
}
|
||||
} while (angle < -360 || angle > 360);
|
||||
|
||||
return Mathf.Clamp(angle, min, max);
|
||||
}
|
||||
|
||||
public static T[] Append<T>(this T[] arrayInitial, T[] arrayToAppend)
|
||||
{
|
||||
if (arrayToAppend == null)
|
||||
{
|
||||
throw new ArgumentNullException("The appended object cannot be null");
|
||||
}
|
||||
if ((arrayInitial is string) || (arrayToAppend is string))
|
||||
{
|
||||
throw new ArgumentException("The argument must be an enumerable");
|
||||
}
|
||||
T[] ret = new T[arrayInitial.Length + arrayToAppend.Length];
|
||||
arrayInitial.CopyTo(ret, 0);
|
||||
arrayToAppend.CopyTo(ret, arrayInitial.Length);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<T> vCopy<T>(this List<T> list)
|
||||
{
|
||||
List<T> _list = new List<T>();
|
||||
if (list == null || list.Count == 0)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
_list.Add(list[i]);
|
||||
}
|
||||
return _list;
|
||||
}
|
||||
|
||||
public static List<T> vToList<T>(this T[] array)
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
if (array == null || array.Length == 0)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
list.Add(array[i]);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static T[] vToArray<T>(this List<T> list)
|
||||
{
|
||||
T[] array = new T[list.Count];
|
||||
if (list == null || list.Count == 0)
|
||||
{
|
||||
return array;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
array[i] = list[i];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static Vector3 BoxSize(this BoxCollider boxCollider)
|
||||
{
|
||||
var length = boxCollider.transform.lossyScale.x * boxCollider.size.x;
|
||||
var width = boxCollider.transform.lossyScale.z * boxCollider.size.z;
|
||||
var height = boxCollider.transform.lossyScale.y * boxCollider.size.y;
|
||||
return new Vector3(length, height, width);
|
||||
}
|
||||
|
||||
public static bool IsClosed(this BoxCollider boxCollider, Vector3 position, Vector3 margin, Vector3 centerOffset)
|
||||
{
|
||||
var size = boxCollider.BoxSize();
|
||||
var marginX = margin.x;
|
||||
var marginY = margin.y;
|
||||
var marginZ = margin.z;
|
||||
var center = boxCollider.center + centerOffset;
|
||||
Vector2 rangeX = new Vector2((center.x - (size.x * 0.5f)) - marginX, (center.x + (size.x * 0.5f)) + marginX);
|
||||
Vector2 rangeY = new Vector2((center.y - (size.y * 0.5f)) - marginY, (center.y + (size.y * 0.5f)) + marginY);
|
||||
Vector2 rangeZ = new Vector2((center.z - (size.z * 0.5f)) - marginZ, (center.z + (size.z * 0.5f)) + marginZ);
|
||||
position = boxCollider.transform.InverseTransformPoint(position);
|
||||
|
||||
bool inX = (position.x * boxCollider.transform.lossyScale.x).IsInSideRange(rangeX);
|
||||
bool inY = (position.y * boxCollider.transform.lossyScale.y).IsInSideRange(rangeY);
|
||||
bool inZ = (position.z * boxCollider.transform.lossyScale.z).IsInSideRange(rangeZ);
|
||||
|
||||
return inX && inY && inZ;
|
||||
}
|
||||
|
||||
public static T ToEnum<T>(this string value, bool ignoreCase = true)
|
||||
{
|
||||
return (T)Enum.Parse(typeof(T), value, ignoreCase);
|
||||
}
|
||||
|
||||
public static bool TryGetField(this object obj, string name, out FieldInfo info)
|
||||
{
|
||||
Type t = obj.GetType();
|
||||
bool found = false;
|
||||
info = null;
|
||||
do
|
||||
{
|
||||
var field = t.GetField(name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
if (field != null)
|
||||
{
|
||||
found = true;
|
||||
info = field;
|
||||
}
|
||||
else
|
||||
{
|
||||
t = t.BaseType;
|
||||
}
|
||||
} while (!found && t != null);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
public static bool Contains<T>(this Enum value, Enum lookingForFlag) where T : struct
|
||||
{
|
||||
int intValue = (int)(object)value;
|
||||
int intLookingForFlag = (int)(object)lookingForFlag;
|
||||
return ((intValue & intLookingForFlag) == intLookingForFlag);
|
||||
}
|
||||
|
||||
public static Vector3 DotVector(this Vector3 _vector, Vector3 _direction)
|
||||
{
|
||||
//Normalize vector if necessary;
|
||||
if (_direction.sqrMagnitude != 1)
|
||||
_direction.Normalize();
|
||||
|
||||
float _amount = Vector3.Dot(_vector, _direction);
|
||||
|
||||
return _direction * _amount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// vTime controls when to use a Time with scale or without scale.
|
||||
/// Use to make functions that doesn't depend on the paused Time scale
|
||||
/// </summary>
|
||||
public static class vTime
|
||||
{
|
||||
public static bool useUnscaledTime = false;
|
||||
static bool unscaledTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return Time.timeScale <= 0 && useUnscaledTime;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Return DeltaTime with unscaled time when <seealso cref="Time.timeScale"/> is Zero
|
||||
/// </summary>
|
||||
public static float deltaTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return !unscaledTime
|
||||
? Time.deltaTime
|
||||
: Time.unscaledDeltaTime;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Return FixedDeltaTime with unscaled time when <seealso cref="Time.timeScale"/> is Zero
|
||||
/// </summary>
|
||||
public static float fixedDeltaTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return !unscaledTime
|
||||
? Time.fixedDeltaTime
|
||||
: Time.fixedUnscaledDeltaTime;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Return Time with unscaled time when <seealso cref="Time.timeScale"/> is Zero
|
||||
/// </summary>
|
||||
public static float time
|
||||
{
|
||||
get
|
||||
{
|
||||
return !unscaledTime
|
||||
? Time.time
|
||||
: Time.unscaledTime;
|
||||
}
|
||||
}
|
||||
public static float GetNormalizedTime(this Animator animator, int layer, int round = 2)
|
||||
{
|
||||
return (float)System.Math.Round(((animator.IsInTransition(layer) ? animator.GetNextAnimatorStateInfo(layer).normalizedTime : animator.GetCurrentAnimatorStateInfo(layer).normalizedTime) % 1), round);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fc1693a704c9e145a47ee927f7b634b
|
||||
timeCreated: 1529517686
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,120 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.Utils
|
||||
{
|
||||
[vClassHeader("Fade Canvas")]
|
||||
public class vFadeCanvas : vMonoBehaviour
|
||||
{
|
||||
public CanvasGroup group;
|
||||
|
||||
public float fadeSpeed = 2f;
|
||||
public UnityEngine.Events.UnityEvent onStartFadeIn, onFinishFadeIn, onStartFadeOut, onFinishFadeOut;
|
||||
public UnityEngine.UI.Slider.SliderEvent OnChangeValue;
|
||||
public bool autoControlCanvasGroup;
|
||||
public bool fadeInStart;
|
||||
public bool fadeOutStart;
|
||||
public bool startWithAlphaZero = true;
|
||||
public bool startWithAlphaFull;
|
||||
|
||||
protected virtual float currentValue { get; set; }
|
||||
protected virtual bool inFade { get; set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (!group) group = GetComponent<CanvasGroup>();
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
InitilizeFadeEffect();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
InitilizeFadeEffect();
|
||||
}
|
||||
|
||||
protected virtual void InitilizeFadeEffect()
|
||||
{
|
||||
if (fadeInStart) FadeIn();
|
||||
if (fadeOutStart) FadeOut();
|
||||
if (startWithAlphaZero) AlphaZero();
|
||||
if (startWithAlphaFull) AlphaFull();
|
||||
}
|
||||
|
||||
public virtual void AlphaZero()
|
||||
{
|
||||
if (group) group.alpha = 0f;
|
||||
}
|
||||
|
||||
public virtual void AlphaFull()
|
||||
{
|
||||
if (group) group.alpha = 1f;
|
||||
}
|
||||
|
||||
public virtual void FadeIn()
|
||||
{
|
||||
StartCoroutine(Fade(1f));
|
||||
}
|
||||
|
||||
public virtual void FadeOut()
|
||||
{
|
||||
StartCoroutine(Fade(0f));
|
||||
}
|
||||
|
||||
public IEnumerator Fade(float targetValue)
|
||||
{
|
||||
if (targetValue == 1)
|
||||
{
|
||||
onStartFadeIn.Invoke();
|
||||
if (autoControlCanvasGroup && group)
|
||||
{
|
||||
group.interactable = false;
|
||||
group.blocksRaycasts = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (autoControlCanvasGroup && group)
|
||||
{
|
||||
group.interactable = false;
|
||||
group.blocksRaycasts = true;
|
||||
}
|
||||
onStartFadeOut.Invoke();
|
||||
}
|
||||
|
||||
inFade = false;
|
||||
yield return new WaitForEndOfFrame();
|
||||
inFade = true;
|
||||
if (group) currentValue = group.alpha;
|
||||
|
||||
while ((targetValue == 1 ? currentValue < 1 : currentValue > 0) && inFade)
|
||||
{
|
||||
yield return null;
|
||||
currentValue = (targetValue == 1) ? currentValue + Time.unscaledDeltaTime * fadeSpeed : currentValue - Time.unscaledDeltaTime * fadeSpeed;
|
||||
if (group) group.alpha = currentValue;
|
||||
OnChangeValue.Invoke(currentValue);
|
||||
}
|
||||
if (targetValue == 1)
|
||||
{
|
||||
onFinishFadeIn.Invoke();
|
||||
if (autoControlCanvasGroup && group)
|
||||
{
|
||||
group.interactable = true;
|
||||
group.blocksRaycasts = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (autoControlCanvasGroup && group)
|
||||
{
|
||||
group.interactable = false;
|
||||
group.blocksRaycasts = false;
|
||||
}
|
||||
|
||||
onFinishFadeOut.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5f8d7f4b54ee5648818cf43b799bb4d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
namespace Invector
|
||||
{
|
||||
[vClassHeader("Frame Limiter", false)]
|
||||
public class vFrameLimiter : vMonoBehaviour
|
||||
{
|
||||
public int desiredFPS = 60;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Application.targetFrameRate = desiredFPS;
|
||||
QualitySettings.vSyncCount = 0;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
//void Update()
|
||||
//{
|
||||
// long lastTicks = DateTime.Now.Ticks;
|
||||
// long currentTicks = lastTicks;
|
||||
// float delay = 1f / desiredFPS;
|
||||
// float elapsedTime;
|
||||
|
||||
// if (desiredFPS <= 0)
|
||||
// return;
|
||||
|
||||
// while (true)
|
||||
// {
|
||||
// currentTicks = DateTime.Now.Ticks;
|
||||
// elapsedTime = (float)TimeSpan.FromTicks(currentTicks - lastTicks).TotalSeconds;
|
||||
// if (elapsedTime >= delay)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4859e9754e89184190caa940804abb0
|
||||
timeCreated: 1513864872
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,78 @@
|
||||
using UnityEngine;
|
||||
|
||||
public struct vGroundPlaneCast
|
||||
{
|
||||
public Vector3 p1, p2, p3, p4;
|
||||
public Vector3 planeNormal;
|
||||
public Vector3 planeCenter;
|
||||
public Vector3 centerNormal;
|
||||
|
||||
public float planeDistance;
|
||||
public bool hasFloor;
|
||||
public readonly int planeAngle
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)Vector3.Angle(Vector3.up, planeNormal);
|
||||
}
|
||||
}
|
||||
RaycastHit hit;
|
||||
|
||||
public void CalculatePlane(Transform transform, Vector3 position, Vector3 down, float distance, LayerMask mask, float plane = 0.5f)
|
||||
{
|
||||
Vector3 basePosition = transform.position;
|
||||
float size = plane * 0.5f;
|
||||
planeNormal = -down;
|
||||
/// p1 --- p2
|
||||
/// | |
|
||||
/// | |
|
||||
/// p4 --- p3
|
||||
p1 = position + transform.forward * size - transform.right * size;
|
||||
p2 = position + transform.forward * size + transform.right * size;
|
||||
p3 = position - transform.forward * size + transform.right * size;
|
||||
p4 = position - transform.forward * size - transform.right * size;
|
||||
//Debug.DrawRay(p1, Vector3.down * distance);
|
||||
//Debug.DrawRay(p2, Vector3.down * distance);
|
||||
//Debug.DrawRay(p3, Vector3.down * distance);
|
||||
//Debug.DrawRay(p4, Vector3.down * distance);
|
||||
|
||||
bool _hasFloor1 = false;
|
||||
bool _hasFloor2 = false;
|
||||
bool _hasFloor3 = false;
|
||||
bool _hasFloor4 = false;
|
||||
if (Physics.Raycast(position, down, out hit, distance, mask))
|
||||
{
|
||||
centerNormal = hit.normal;
|
||||
planeCenter = hit.point;
|
||||
}
|
||||
else planeCenter = transform.position + Vector3.down * distance;
|
||||
if (Physics.Raycast(p1, down, out hit, distance, mask)) { p1 = hit.point; _hasFloor1 = true; }
|
||||
else p1 = basePosition + Vector3.forward * size + Vector3.left * size;
|
||||
if (Physics.Raycast(p2, down, out hit, distance, mask)) { p2 = hit.point; _hasFloor2 = true; }
|
||||
else p2 = basePosition + Vector3.forward * size + Vector3.right * size;
|
||||
if (Physics.Raycast(p3, down, out hit, distance, mask)) { p3 = hit.point; _hasFloor3 = true; }
|
||||
else p3 = basePosition + Vector3.back * size + Vector3.right * size;
|
||||
if (Physics.Raycast(p4, down, out hit, distance, mask)) { p4 = hit.point; _hasFloor4 = true; }
|
||||
else p4 = basePosition + Vector3.back * size + Vector3.left * size;
|
||||
var _planeCenter = (p1 + p2 + p3 + p4) / 4;
|
||||
//if (_planeCenter.y > hit.point.y)
|
||||
//{
|
||||
planeCenter = _planeCenter;
|
||||
//}
|
||||
planeNormal = (-GetNormal(p1, p2, p3)) + (-GetNormal(p2, p1, p3)) + (-GetNormal(p3, p2, p4)) + (-GetNormal(p4, p3, p1));
|
||||
|
||||
planeDistance = (position - planeCenter).magnitude;
|
||||
hasFloor = (_hasFloor1 || _hasFloor2 || _hasFloor3 || _hasFloor4);
|
||||
|
||||
}
|
||||
|
||||
readonly Vector3 GetNormal(Vector3 a, Vector3 b, Vector3 c)
|
||||
{
|
||||
// Find vectors corresponding to two of the sides of the triangle.
|
||||
Vector3 side1 = b - a;
|
||||
Vector3 side2 = c - a;
|
||||
|
||||
// Cross the vectors to get a perpendicular vector, then normalize it.
|
||||
return Vector3.Cross(side1, side2).normalized;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5ebc2e2635b84a6aa9d472ce0e7002f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,105 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[vClassHeader("HITDAMAGE PARTICLE", "Default hit Particle to instantiate every time you receive damage and Custom hit Particle to instantiate based on a custom DamageType that comes from the MeleeControl Behaviour (AnimatorController)")]
|
||||
public class vHitDamageParticle : vMonoBehaviour
|
||||
{
|
||||
public List<GameObject> defaultDamageEffects = new List<GameObject>();
|
||||
public List<vDamageEffect> customDamageEffects = new List<vDamageEffect>();
|
||||
|
||||
private vFisherYatesRandom _random;
|
||||
|
||||
IEnumerator Start()
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
if (TryGetComponent<vIHealthController>(out vIHealthController healthController))
|
||||
{
|
||||
healthController.onReceiveDamage.AddListener(OnReceiveDamage);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnReceiveDamage(vDamage damage)
|
||||
{
|
||||
// instantiate the hitDamage particle - check if your character has a HitDamageParticle component
|
||||
var damageDirection = damage.hitPosition - new Vector3(transform.position.x, damage.hitPosition.y, transform.position.z);
|
||||
var hitRotation = damageDirection != Vector3.zero ? Quaternion.LookRotation(damageDirection) : transform.rotation;
|
||||
|
||||
if (damage.damageValue > 0)
|
||||
{
|
||||
TriggerEffect(new vDamageEffectInfo(damage.hitPosition, hitRotation, damage.damageType, damage.receiver));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the hit event.
|
||||
/// </summary>
|
||||
/// <param name="damageEffectInfo">Hit effect info.</param>
|
||||
protected virtual void TriggerEffect(vDamageEffectInfo damageEffectInfo)
|
||||
{
|
||||
if (_random == null)
|
||||
{
|
||||
_random = new vFisherYatesRandom();
|
||||
}
|
||||
var damageEffect = customDamageEffects.Find(effect => effect.damageType.Equals(damageEffectInfo.damageType));
|
||||
|
||||
if (damageEffect != null)
|
||||
{
|
||||
damageEffect.onTriggerEffect.Invoke();
|
||||
if (damageEffect.customDamageEffect != null && damageEffect.customDamageEffect.Count > 0)
|
||||
{
|
||||
var randomCustomEffect = damageEffect.customDamageEffect[_random.Next(damageEffect.customDamageEffect.Count)];
|
||||
|
||||
Instantiate(randomCustomEffect, damageEffectInfo.position,
|
||||
damageEffect.rotateToHitDirection ? damageEffectInfo.rotation : randomCustomEffect.transform.rotation,
|
||||
damageEffect.attachInReceiver && damageEffectInfo.receiver ? damageEffectInfo.receiver : vObjectContainer.root);
|
||||
}
|
||||
}
|
||||
else if (defaultDamageEffects.Count > 0 && damageEffectInfo != null)
|
||||
{
|
||||
var randomDefaultEffect = defaultDamageEffects[_random.Next(defaultDamageEffects.Count)];
|
||||
Instantiate(randomDefaultEffect, damageEffectInfo.position, damageEffectInfo.rotation, vObjectContainer.root);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Reset()
|
||||
{
|
||||
defaultDamageEffects = new List<GameObject>();
|
||||
var defaultEffect = Resources.Load("defaultDamageEffect");
|
||||
|
||||
if (defaultEffect != null)
|
||||
{
|
||||
defaultDamageEffects.Add(defaultEffect as GameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class vDamageEffectInfo
|
||||
{
|
||||
public Transform receiver;
|
||||
public Vector3 position;
|
||||
public Quaternion rotation;
|
||||
public string damageType;
|
||||
public vDamageEffectInfo(Vector3 position, Quaternion rotation, string damageType = "", Transform receiver = null)
|
||||
{
|
||||
this.receiver = receiver;
|
||||
this.position = position;
|
||||
this.rotation = rotation;
|
||||
this.damageType = damageType;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class vDamageEffect
|
||||
{
|
||||
public string damageType = "";
|
||||
public List<GameObject> customDamageEffect;
|
||||
public bool rotateToHitDirection = true;
|
||||
[Tooltip("Attach prefab in Damage Receiver transform")]
|
||||
public bool attachInReceiver = false;
|
||||
public UnityEvent onTriggerEffect;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d3efef3ad62cd548b0f85eb11858ed1
|
||||
timeCreated: 1522433365
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- defaultDamageEffect: {fileID: 120346, guid: b8f2fe1ee1a01724cb72f5b0e6bd2eef,
|
||||
type: 2}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
namespace Invector
|
||||
{
|
||||
public class vImageColorChange : MonoBehaviour
|
||||
{
|
||||
public Image image;
|
||||
public Color[] colors;
|
||||
|
||||
public void ChangeColor(int colorIndex)
|
||||
{
|
||||
if (colors.Length > 0 && colorIndex < colors.Length)
|
||||
{
|
||||
image.color = colors[colorIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d75df3864c0a0214eb31804fce00aba8
|
||||
timeCreated: 1517007691
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.Utils
|
||||
{
|
||||
[vClassHeader("v Instantiate", openClose = false)]
|
||||
public class vInstantiate : vMonoBehaviour
|
||||
{
|
||||
public GameObject prefab;
|
||||
public bool instantiateOnStart;
|
||||
public bool setThisAsParent;
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
if (instantiateOnStart)
|
||||
InstantiateObject();
|
||||
}
|
||||
|
||||
public virtual void InstantiateObject()
|
||||
{
|
||||
if (prefab)
|
||||
{
|
||||
var obj = Instantiate(prefab, transform.position, transform.rotation);
|
||||
obj.SetActive(true);
|
||||
if (setThisAsParent) obj.transform.parent = transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de8c6f6fb33efc547afa68f68e220d74
|
||||
timeCreated: 1542765581
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
using UnityEngine;
|
||||
namespace Invector
|
||||
{
|
||||
public class vLookAtCamera : MonoBehaviour
|
||||
{
|
||||
[Tooltip("Align position to stay always on top of parent")]
|
||||
public bool alignUp = false;
|
||||
[Tooltip("Height of alignment on top of parent \n!!(Check alignUp to work)!!")]
|
||||
public float height = 1;
|
||||
[Tooltip("Detach of the parent on start \n!!(if alignUp not is checked, the object not follow the parent)!!")]
|
||||
public bool detachOnStart;
|
||||
[Tooltip("use smoth to look at camera")]
|
||||
public bool useSmothRotation = true;
|
||||
protected Transform parent;
|
||||
public bool justY;
|
||||
internal Camera cameraMain;
|
||||
void Start()
|
||||
{
|
||||
if (detachOnStart)
|
||||
{
|
||||
parent = transform.parent;
|
||||
transform.SetParent(null);
|
||||
}
|
||||
cameraMain = Camera.main;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
cameraMain = Camera.main;
|
||||
Align(false);
|
||||
}
|
||||
void FixedUpdate()
|
||||
{
|
||||
Align(useSmothRotation);
|
||||
}
|
||||
void Align(bool useSmooth)
|
||||
{
|
||||
if (alignUp && parent)
|
||||
transform.position = parent.position + Vector3.up * height;
|
||||
if (!cameraMain) return;
|
||||
var lookPos = cameraMain.transform.position - transform.position;
|
||||
lookPos.y = 0;
|
||||
var rotation = Quaternion.LookRotation(lookPos);
|
||||
if (useSmooth)
|
||||
{
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 4f);
|
||||
transform.eulerAngles = new Vector3(justY ? 0 : transform.eulerAngles.x, transform.eulerAngles.y, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.eulerAngles = new Vector3(justY ? 0 : rotation.eulerAngles.x, rotation.eulerAngles.y, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5bfa2d224a49724b94dd6c24553be35
|
||||
timeCreated: 1494349638
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,114 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[vClassHeader("MESSAGE RECEIVER", "Use this component with the vMessageSender to call Events.")]
|
||||
public class vMessageReceiver : vMonoBehaviour
|
||||
{
|
||||
public static event OnReceiveMessage onReceiveGlobalMessage;
|
||||
public List<vMessageListener> messagesListeners;
|
||||
[System.Serializable]
|
||||
public delegate void OnReceiveMessage(string name, string message = null);
|
||||
[System.Serializable]
|
||||
public class OnReceiveMessageEvent : UnityEngine.Events.UnityEvent<string> { }
|
||||
|
||||
public event OnReceiveMessage onReceiveMessage;
|
||||
private void Start()
|
||||
{
|
||||
for (int i = 0; i < messagesListeners.Count; i++)
|
||||
{
|
||||
vMessageListener messageListener = messagesListeners[i];
|
||||
if (messageListener.receiveFromGlobal)
|
||||
{
|
||||
onReceiveGlobalMessage -= messageListener.OnReceiveMessage;
|
||||
onReceiveGlobalMessage += messageListener.OnReceiveMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
onReceiveMessage -= messageListener.OnReceiveMessage;
|
||||
onReceiveMessage += messageListener.OnReceiveMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
[System.Serializable]
|
||||
public class vMessageListener
|
||||
{
|
||||
public string Name;
|
||||
public bool receiveFromGlobal;
|
||||
public OnReceiveMessageEvent onReceiveMessage;
|
||||
|
||||
public void OnReceiveMessage(string name, string message = null)
|
||||
{
|
||||
if (Name.Equals(name)) onReceiveMessage.Invoke(string.IsNullOrEmpty(message) ? string.Empty : message);
|
||||
|
||||
}
|
||||
public vMessageListener(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
public vMessageListener(string name, UnityEngine.Events.UnityAction<string> listener)
|
||||
{
|
||||
this.Name = name;
|
||||
this.onReceiveMessage.AddListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add Action Listener
|
||||
/// </summary>
|
||||
/// <param name="name">Message Name</param>
|
||||
/// <param name="listener">Action Listener</param>
|
||||
public void AddListener(string name, UnityEngine.Events.UnityAction<string> listener)
|
||||
{
|
||||
if (messagesListeners.Exists(l => l.Name.Equals(name)))
|
||||
{
|
||||
var messageListener = messagesListeners.Find(l => l.Name.Equals(name));
|
||||
messageListener.onReceiveMessage.AddListener(listener);
|
||||
}
|
||||
else
|
||||
{
|
||||
messagesListeners.Add(new vMessageListener(name, listener));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove Action Listener
|
||||
/// </summary>
|
||||
/// <param name="name">Message Name</param>
|
||||
/// <param name="listener">Action Listener</param>
|
||||
public void RemoveListener(string name, UnityEngine.Events.UnityAction<string> listener)
|
||||
{
|
||||
if (messagesListeners.Exists(l => l.Name.Equals(name)))
|
||||
{
|
||||
var messageListener = messagesListeners.Find(l => l.Name.Equals(name));
|
||||
messageListener.onReceiveMessage.RemoveListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call Action without message
|
||||
/// </summary>
|
||||
/// <param name="name">message name</param>
|
||||
public void Send(string name)
|
||||
{
|
||||
if (this.enabled == false) return;
|
||||
onReceiveMessage?.Invoke(name, string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call Action with message
|
||||
/// </summary>
|
||||
/// <param name="name">message name</param>
|
||||
/// <param name="message">message value</param>
|
||||
public void Send(string name, string message)
|
||||
{
|
||||
if (this.enabled == false) return;
|
||||
onReceiveMessage?.Invoke(name, message);
|
||||
}
|
||||
|
||||
public static void SendGlobal(string name, string message = null)
|
||||
{
|
||||
onReceiveGlobalMessage?.Invoke(name, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 605ff11ee57b0c241a82c0c37c40c0bc
|
||||
timeCreated: 1524243779
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,242 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[vClassHeader("Message Sender", "Requires a vMessageReceiver to receive messages.", openClose = false)]
|
||||
public class vMessageSender : vMonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public class vMessage
|
||||
{
|
||||
public string name;
|
||||
public string message;
|
||||
[vHelpBox("- sendByTrigger (You can use vSimpleTrigger to verify the Player and Send messages using Events by calling the 'OnTrigger' method")]
|
||||
public bool sendByTrigger;
|
||||
public List<vMessageReceiver> defaultReceivers;
|
||||
}
|
||||
[System.Serializable]
|
||||
public class vGlobalMessage
|
||||
{
|
||||
public string name;
|
||||
public string message;
|
||||
}
|
||||
public List<vMessage> messages;
|
||||
public List<vGlobalMessage> globalMessages;
|
||||
/// <summary>
|
||||
/// Send a message to default receiver of the target message
|
||||
/// </summary>
|
||||
/// <param name="messageIndex">index of message list</param>
|
||||
public virtual void SendToDefaultReceiver(int messageIndex)
|
||||
{
|
||||
|
||||
vMessage _message = messages.Count > 0 && messageIndex < messages.Count ? messages[messageIndex] : null;
|
||||
if (_message != null)
|
||||
for (int i = 0; i < _message.defaultReceivers.Count; i++)
|
||||
if (_message.defaultReceivers[i])
|
||||
_message.defaultReceivers[i].Send(_message.name, _message.message);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to default receiver of the target message
|
||||
/// </summary>
|
||||
/// <param name="messageName">name of message in message list</param>
|
||||
public virtual void SendToDefaultReceiver(string messageName)
|
||||
{
|
||||
var _messages = messages.FindAll(m => m.name.Equals(messageName));
|
||||
if (_messages != null && _messages.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < _messages.Count; i++)
|
||||
{
|
||||
for (int a = 0; a < _messages[i].defaultReceivers.Count; a++)
|
||||
if (_messages[i].defaultReceivers[a])
|
||||
_messages[i].defaultReceivers[a].Send(_messages[i].name, _messages[i].message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to default receiver of the target message
|
||||
/// </summary>
|
||||
/// <param name="messageIndex">index of message list</param>
|
||||
public virtual void SendToParentReceiver(int messageIndex)
|
||||
{
|
||||
var receiver = GetComponentInParent<vMessageReceiver>();
|
||||
|
||||
if (!receiver) return;
|
||||
|
||||
vMessage _message = messages.Count > 0 && messageIndex < messages.Count ? messages[messageIndex] : null;
|
||||
if (_message != null)
|
||||
{
|
||||
receiver.Send(_message.name, _message.message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to default receiver of the target message
|
||||
/// </summary>
|
||||
/// <param name="messageName">name of message in message list</param>
|
||||
public virtual void SendToParentReceiver(string messageName)
|
||||
{
|
||||
var receiver = GetComponentInParent<vMessageReceiver>();
|
||||
if (!receiver) return;
|
||||
var _messages = messages.FindAll(m => m.name.Equals(messageName));
|
||||
if (_messages != null && _messages.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < _messages.Count; i++)
|
||||
{
|
||||
receiver.Send(_messages[i].name, _messages[i].message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to target receiver
|
||||
/// </summary>
|
||||
/// <param name="messageIndex">index of message list</param>
|
||||
/// <param name="target">target receiver</param>
|
||||
public virtual void Send(GameObject target, int messageIndex)
|
||||
{
|
||||
if (target) return;
|
||||
var _receiver = target.GetComponent<vMessageReceiver>();
|
||||
if (!_receiver) return;
|
||||
vMessage _message = messages.Count > 0 && messageIndex < messages.Count ? messages[messageIndex] : null;
|
||||
if (_message != null) _receiver.Send(_message.name, _message.message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to target receiver
|
||||
/// </summary>
|
||||
/// <param name="messageIndex">index of message list</param>
|
||||
/// <param name="target">target receiver</param>
|
||||
public virtual void Send(Collider target, int messageIndex)
|
||||
{
|
||||
if (target) return;
|
||||
Send(target.gameObject, messageIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to target receiver
|
||||
/// </summary>
|
||||
/// <param name="messageIndex">index of message list</param>
|
||||
/// <param name="target">target receiver</param>
|
||||
public virtual void Send(Transform target, int messageIndex)
|
||||
{
|
||||
if (target) return;
|
||||
Send(target.gameObject, messageIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to target receiver
|
||||
/// </summary>
|
||||
/// <param name="messageName">name of message in message list</param>
|
||||
/// <param name="target">target receiver</param>
|
||||
public virtual void Send(GameObject target, string messageName)
|
||||
{
|
||||
if (target) return;
|
||||
var _receiver = target.GetComponent<vMessageReceiver>();
|
||||
if (!_receiver) return;
|
||||
var _messages = messages.FindAll(m => m.name.Equals(messageName));
|
||||
if (_messages != null && _messages.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < _messages.Count; i++)
|
||||
{
|
||||
_receiver.Send(_messages[i].name, _messages[i].message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send messages defined as <seealso cref="vMessage.sendByTrigger"/>.
|
||||
/// <para>Call this function using vSimpleTrigger event or similar</para>
|
||||
/// </summary>
|
||||
/// <param name="target">target Receiver</param>
|
||||
public virtual void Send(Collider target, string messageName)
|
||||
{
|
||||
if (!target) return;
|
||||
Send(target.gameObject, messageName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send messages defined as <seealso cref="vMessage.sendByTrigger"/>.
|
||||
/// <para>Call this function using vSimpleTrigger event or similar</para>
|
||||
/// </summary>
|
||||
/// <param name="target">target Receiver</param>
|
||||
public virtual void Send(Transform target, string messageName)
|
||||
{
|
||||
if (!target) return;
|
||||
Send(target.gameObject, messageName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send all message to default receiver
|
||||
/// </summary>
|
||||
public virtual void SendAllToDefaultReceiver()
|
||||
{
|
||||
if (messages != null && messages.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < messages.Count; i++)
|
||||
{
|
||||
for (int a = 0; a < messages[i].defaultReceivers.Count; a++)
|
||||
if (messages[i].defaultReceivers[a])
|
||||
messages[i].defaultReceivers[a].Send(messages[i].name, messages[i].message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send all message to target receiver
|
||||
/// </summary>
|
||||
/// <param name="target">target receiver</param>
|
||||
public virtual void SendAll(GameObject target)
|
||||
{
|
||||
if (!target) return;
|
||||
var _receiver = target.GetComponent<vMessageReceiver>();
|
||||
if (!_receiver) return;
|
||||
for (int i = 0; i < messages.Count; i++) _receiver.Send(messages[i].name, messages[i].message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send messages defined as <seealso cref="vMessage.sendByTrigger"/>.
|
||||
/// <para>Call this function using vSimpleTrigger event or similar</para>
|
||||
/// </summary>
|
||||
/// <param name="target">target Receiver</param>
|
||||
public virtual void OnTrigger(Collider target)
|
||||
{
|
||||
if (!target) return;
|
||||
var _receiver = target.gameObject.GetComponent<vMessageReceiver>();
|
||||
if (!_receiver) return;
|
||||
for (int i = 0; i < messages.Count; i++)
|
||||
if (messages[i].sendByTrigger) _receiver.Send(messages[i].name, messages[i].message);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send message to global receivers
|
||||
/// </summary>
|
||||
/// <param name="messageName">Message name</param>
|
||||
public virtual void SendGlobal(string messageName)
|
||||
{
|
||||
var _messages = globalMessages.FindAll(m => m.name.Equals(messageName));
|
||||
for (int i = 0; i < _messages.Count; i++)
|
||||
{
|
||||
vMessageReceiver.SendGlobal(_messages[i].name, _messages[i].message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send message to global receivers
|
||||
/// </summary>
|
||||
/// <param name="messageIndex">Index of Message</param>
|
||||
public virtual void SendGlobal(int messageIndex)
|
||||
{
|
||||
vGlobalMessage _message = globalMessages.Count > 0 && messageIndex < globalMessages.Count ? globalMessages[messageIndex] : null;
|
||||
if (_message != null)
|
||||
{
|
||||
vMessageReceiver.SendGlobal(_message.name, _message.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0e466b9b18791a488af4fe3e0da275b
|
||||
timeCreated: 1538075242
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
public class vMonoBehaviour : MonoBehaviour
|
||||
{
|
||||
[SerializeField, HideInInspector]
|
||||
private bool openCloseEvents ;
|
||||
[SerializeField, HideInInspector]
|
||||
private bool openCloseWindow;
|
||||
[SerializeField, HideInInspector]
|
||||
private int selectedToolbar;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83b41375dbfb9e648b8c7e7cd4bff7f2
|
||||
timeCreated: 1529517514
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,227 @@
|
||||
using UnityEngine;
|
||||
|
||||
#if MOBILE_INPUT
|
||||
using UnityStandardAssets.CrossPlatformInput;
|
||||
#endif
|
||||
|
||||
namespace Invector.vCharacterController
|
||||
{
|
||||
public class vMousePositionHandler : MonoBehaviour
|
||||
{
|
||||
public Camera mainCamera;
|
||||
protected static vMousePositionHandler _instance;
|
||||
public static vMousePositionHandler Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = FindObjectOfType<vMousePositionHandler>();
|
||||
}
|
||||
|
||||
if (_instance == null)
|
||||
{
|
||||
var go = new GameObject("MousePositionHandler");
|
||||
_instance = go.AddComponent<vMousePositionHandler>();
|
||||
_instance.mainCamera = Camera.main;
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public string joystickHorizontalAxis = "RightAnalogHorizontal";
|
||||
public string joystickVerticalAxis = "RightAnalogVertical";
|
||||
public float joystickSensitivity = 25f;
|
||||
public bool clampScreen = true;
|
||||
|
||||
public Vector2 joystickMousePos;
|
||||
|
||||
public virtual void SetMousePosition(Vector2 pos)
|
||||
{
|
||||
joystickMousePos = pos;
|
||||
}
|
||||
|
||||
public virtual Vector2 mousePosition
|
||||
{
|
||||
get
|
||||
{
|
||||
var inputDevice = vInput.instance.inputDevice;
|
||||
switch (inputDevice)
|
||||
{
|
||||
case InputDevice.MouseKeyboard:
|
||||
return Input.mousePosition;
|
||||
case InputDevice.Joystick:
|
||||
joystickMousePos.x += Input.GetAxis("RightAnalogHorizontal") * joystickSensitivity;
|
||||
joystickMousePos.x = Mathf.Clamp(joystickMousePos.x, -(Screen.width * 0.5f), (Screen.width * 0.5f));
|
||||
joystickMousePos.y += Input.GetAxis("RightAnalogVertical") * joystickSensitivity;
|
||||
joystickMousePos.y = Mathf.Clamp(joystickMousePos.y, -(Screen.height * 0.5f), (Screen.height * 0.5f));
|
||||
var screenCenter = new Vector2(Screen.width * 0.5f, Screen.height * 0.5f);
|
||||
var result = joystickMousePos + screenCenter;
|
||||
result.x = Mathf.Clamp(result.x, 0, Screen.width);
|
||||
result.y = Mathf.Clamp(result.y, 0, Screen.height);
|
||||
return result;
|
||||
case InputDevice.Mobile:
|
||||
if (clampScreen)
|
||||
{
|
||||
#if MOBILE_INPUT
|
||||
joystickMousePos.x += CrossPlatformInputManager.GetAxis("RightAnalogHorizontal") * joystickSensitivity;
|
||||
joystickMousePos.x = Mathf.Clamp(joystickMousePos.x, -(Screen.width * 0.5f), (Screen.width * 0.5f));
|
||||
joystickMousePos.y += CrossPlatformInputManager.GetAxis("RightAnalogVertical") * joystickSensitivity;
|
||||
joystickMousePos.y = Mathf.Clamp(joystickMousePos.y, -(Screen.height * 0.5f), (Screen.height * 0.5f));
|
||||
var mobileScreenCenter = new Vector2(Screen.width * 0.5f, Screen.height * 0.5f);
|
||||
var mobileResult = joystickMousePos + mobileScreenCenter;
|
||||
mobileResult.x = Mathf.Clamp(mobileResult.x, 0, Screen.width);
|
||||
mobileResult.y = Mathf.Clamp(mobileResult.y, 0, Screen.height);
|
||||
return mobileResult;
|
||||
#else
|
||||
return Input.GetTouch(0).deltaPosition;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
return joystickMousePos;
|
||||
}
|
||||
|
||||
default: return Input.mousePosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Vector3 WorldMousePosition(LayerMask castLayer, out Collider collider)
|
||||
{
|
||||
if (!mainCamera)
|
||||
{
|
||||
if (!Camera.main)
|
||||
{
|
||||
Debug.LogWarning("Trying to get the world mouse position but a MainCamera is missing from the scene");
|
||||
collider = null;
|
||||
return Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainCamera = Camera.main;
|
||||
collider = null;
|
||||
return Vector3.zero;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Ray ray = mainCamera.ScreenPointToRay(mousePosition);
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.Raycast(ray, out hit, mainCamera.farClipPlane, castLayer))
|
||||
{
|
||||
collider = hit.collider;
|
||||
return hit.point;
|
||||
}
|
||||
else
|
||||
{
|
||||
collider = null;
|
||||
return ray.GetPoint(mainCamera.farClipPlane);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CastWorldMousePosition(LayerMask castLayer,out RaycastHit hit,float distance =0)
|
||||
{
|
||||
if (!mainCamera)
|
||||
{
|
||||
if (!Camera.main)
|
||||
{
|
||||
Debug.LogWarning("Trying to get the world mouse position but a MainCamera is missing from the scene");
|
||||
hit = default;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainCamera = Camera.main;
|
||||
hit = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Ray ray = mainCamera.ScreenPointToRay(mousePosition);
|
||||
|
||||
|
||||
if (Physics.Raycast(ray, out hit,distance==0? mainCamera.farClipPlane:distance, castLayer))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hit = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CastWorldMousePosition(LayerMask castLayer, out RaycastHit hit, float distance = 0,float radius =0f)
|
||||
{
|
||||
if (!mainCamera)
|
||||
{
|
||||
if (!Camera.main)
|
||||
{
|
||||
Debug.LogWarning("Trying to get the world mouse position but a MainCamera is missing from the scene");
|
||||
hit = default;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainCamera = Camera.main;
|
||||
hit = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(radius==0)
|
||||
{
|
||||
return CastWorldMousePosition(castLayer, out hit, distance);
|
||||
}
|
||||
Ray ray = mainCamera.ScreenPointToRay(mousePosition);
|
||||
|
||||
if (Physics.SphereCast(ray,radius, out hit, distance == 0 ? mainCamera.farClipPlane : distance, castLayer))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hit = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Vector3 WorldMousePosition(LayerMask castLayer)
|
||||
{
|
||||
if (!mainCamera)
|
||||
{
|
||||
if (!Camera.main)
|
||||
{
|
||||
Debug.LogWarning("Trying to get the world mouse position but a MainCamera is missing from the scene");
|
||||
return Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainCamera = Camera.main;
|
||||
return Vector3.zero;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Ray ray = mainCamera.ScreenPointToRay(mousePosition);
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.Raycast(ray, out hit, mainCamera.farClipPlane, castLayer))
|
||||
{
|
||||
return hit.point;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ray.GetPoint(mainCamera.farClipPlane);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f72e42ce6c863243a7d2aa78cb7a11f
|
||||
timeCreated: 1502482544
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,102 @@
|
||||
using Invector;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[vClassHeader("Mult-Toggle Event", helpBoxText = "Use the method SetToggleOn/Off via Events", openClose = false)]
|
||||
public class vMultToggleEvent : vMonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public class Toggle
|
||||
{
|
||||
public string name;
|
||||
[Header("Current Value of the toogle")]
|
||||
public bool value;
|
||||
[Header("Validation to compare with value")]
|
||||
public bool validation;
|
||||
|
||||
public void ToggleOn()
|
||||
{
|
||||
value = true;
|
||||
onTurnOn.Invoke();
|
||||
}
|
||||
public void ToggleOff()
|
||||
{
|
||||
value = false;
|
||||
onTurnOff.Invoke();
|
||||
}
|
||||
public bool isValid => value.Equals(validation);
|
||||
public UnityEngine.Events.UnityEvent onTurnOn, onTurnOff;
|
||||
}
|
||||
public List<Toggle> toggles;
|
||||
public bool isValid;
|
||||
|
||||
public UnityEngine.Events.UnityEvent onValidate, onInvalidate;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
CheckValidation();
|
||||
}
|
||||
public void ToggleOn(int index)
|
||||
{
|
||||
if (toggles.Count > 0 && index < toggles.Count)
|
||||
{
|
||||
toggles[index].ToggleOn();
|
||||
CheckValidation();
|
||||
}
|
||||
}
|
||||
public void ToggleOff(int index)
|
||||
{
|
||||
if (toggles.Count > 0 && index < toggles.Count)
|
||||
{
|
||||
toggles[index].ToggleOff();
|
||||
CheckValidation();
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleOn(string name)
|
||||
{
|
||||
var toogle = toggles.Find(t => t.name.Equals(name));
|
||||
if (toogle != null)
|
||||
{
|
||||
toogle.ToggleOn();
|
||||
CheckValidation();
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleOff(string name)
|
||||
{
|
||||
var toogle = toggles.Find(t => t.name.Equals(name));
|
||||
if (toogle != null)
|
||||
{
|
||||
toogle.ToggleOff();
|
||||
CheckValidation();
|
||||
}
|
||||
}
|
||||
|
||||
void CheckValidation()
|
||||
{
|
||||
var _isValid = isValid;
|
||||
var validToggles = toggles.FindAll(t => t.isValid);
|
||||
if (validToggles.Count == toggles.Count)
|
||||
{
|
||||
_isValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isValid = false;
|
||||
}
|
||||
|
||||
if (_isValid != isValid)
|
||||
{
|
||||
isValid = _isValid;
|
||||
if (isValid)
|
||||
{
|
||||
onValidate.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
onInvalidate.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af589d3ff93671345a1d4a4a38b4a763
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class vObjectContainer : MonoBehaviour
|
||||
{
|
||||
|
||||
static vObjectContainer instance;
|
||||
public static Transform root
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!instance)
|
||||
{
|
||||
instance = new GameObject("Object Container", typeof(vObjectContainer)).GetComponent<vObjectContainer>();
|
||||
}
|
||||
return instance.transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d621a553674c1f14c9f947369d35eb15
|
||||
timeCreated: 1529518726
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class vParticleEmissionByVelocity : MonoBehaviour
|
||||
{
|
||||
public Rigidbody rigidbodyReference;
|
||||
public ParticleSystem particle;
|
||||
|
||||
ParticleSystem.EmissionModule emmision;
|
||||
|
||||
|
||||
public bool normalizeVelocity = true;
|
||||
|
||||
public bool inverse;
|
||||
float rate;
|
||||
private void Start()
|
||||
{
|
||||
emmision = particle.emission;
|
||||
rate = emmision.rateOverTime.constant;
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
private void FixedUpdate()
|
||||
{
|
||||
var velocity = rigidbodyReference.linearVelocity;
|
||||
velocity.y = 0;
|
||||
float magnitude = velocity.magnitude;
|
||||
|
||||
float speed = 0f;
|
||||
if (normalizeVelocity)
|
||||
{
|
||||
speed = velocity.normalized.magnitude * Mathf.Clamp(magnitude, 0, 1f);
|
||||
}
|
||||
else speed = magnitude;
|
||||
if (inverse)
|
||||
emmision.rateOverTime = rate - (rate * speed);
|
||||
else emmision.rateOverTime = rate * speed;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 794de24f8093a0a42945ab68fd416a4f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,105 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class vPingPongRotation : MonoBehaviour
|
||||
{
|
||||
[vHelpBox("This Component needs to be child of a root transform")]
|
||||
[vMinMax(-180, 180)]
|
||||
public Vector2 angleX;
|
||||
[vMinMax(-180, 180)]
|
||||
public Vector2 angleY;
|
||||
[vMinMax(-180, 180)]
|
||||
public Vector2 angleZ;
|
||||
|
||||
public Vector3 speed = Vector3.one;
|
||||
|
||||
Vector3 pingPongTime;
|
||||
Vector3 euler;
|
||||
float evaluateToDirection;
|
||||
Vector3 defaultLocalForward;
|
||||
public Transform targetTransform;
|
||||
Vector3 evaluate;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (targetTransform == null)
|
||||
{
|
||||
targetTransform = transform;
|
||||
}
|
||||
|
||||
defaultLocalForward = targetTransform.parent.InverseTransformDirection(targetTransform.forward);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
evaluateToDirection = 0;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
evaluateToDirection = 0;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Vector3 forward = targetTransform.parent.TransformDirection(defaultLocalForward);
|
||||
if (angleX.magnitude > 0)
|
||||
{
|
||||
pingPongTime.x = Time.time * speed.x;
|
||||
}
|
||||
|
||||
if (angleY.magnitude > 0)
|
||||
{
|
||||
pingPongTime.y = Time.time * speed.y;
|
||||
}
|
||||
|
||||
if (angleZ.magnitude > 0)
|
||||
{
|
||||
pingPongTime.z = Time.time * speed.z;
|
||||
}
|
||||
|
||||
if (evaluateToDirection < 1)
|
||||
{
|
||||
evaluateToDirection += Time.deltaTime * speed.magnitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
evaluateToDirection = 1;
|
||||
}
|
||||
|
||||
if (angleX.magnitude > 0)
|
||||
{
|
||||
evaluate.x = Mathf.PingPong(pingPongTime.x, 1f);
|
||||
}
|
||||
|
||||
if (angleY.magnitude > 0)
|
||||
{
|
||||
evaluate.y = Mathf.PingPong(pingPongTime.y, 1f);
|
||||
}
|
||||
|
||||
if (angleZ.magnitude > 0)
|
||||
{
|
||||
pingPongTime.z = Time.time * speed.z;
|
||||
}
|
||||
|
||||
evaluate.z = Mathf.PingPong(pingPongTime.z, 1f);
|
||||
|
||||
if (angleX.magnitude > 0)
|
||||
{
|
||||
euler.x = Mathf.Lerp(angleX.x, angleX.y, evaluate.x);
|
||||
}
|
||||
|
||||
if (angleY.magnitude > 0)
|
||||
{
|
||||
euler.y = Mathf.Lerp(angleY.x, angleY.y, evaluate.y);
|
||||
}
|
||||
|
||||
if (angleZ.magnitude > 0)
|
||||
{
|
||||
pingPongTime.z = Time.time * speed.z;
|
||||
}
|
||||
|
||||
euler.z = Mathf.Lerp(angleZ.x, angleZ.y, evaluate.z);
|
||||
|
||||
targetTransform.forward = Vector3.Lerp(forward, Quaternion.Euler(euler) * forward, evaluateToDirection);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 597ce94d52484b24584286ddbb052098
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
namespace Invector
|
||||
{
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class vPlayRandomClip : MonoBehaviour
|
||||
{
|
||||
|
||||
public AudioClip[] clips;
|
||||
public AudioSource audioSource;
|
||||
public bool playOnStart = true;
|
||||
#if !UNITY_5_4_OR_NEWER
|
||||
protected System.Random random;
|
||||
#endif
|
||||
void Start()
|
||||
{
|
||||
if (!audioSource) audioSource = GetComponent<AudioSource>();
|
||||
Random.InitState(Random.Range(0, System.DateTime.Now.Millisecond));
|
||||
if (playOnStart)
|
||||
{
|
||||
Play();
|
||||
}
|
||||
}
|
||||
public void Play()
|
||||
{
|
||||
if (audioSource)
|
||||
{
|
||||
var index = 0;
|
||||
|
||||
index = Random.Range(0, clips.Length - 1);
|
||||
if (clips.Length > 0)
|
||||
audioSource.PlayOneShot(clips[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c97065fcce0140c479f08ad868d95753
|
||||
timeCreated: 1474928127
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
namespace Invector.Utils
|
||||
{
|
||||
public class vRandomFloat : MonoBehaviour
|
||||
{
|
||||
public bool randomValue = true;
|
||||
[vHideInInspector("randomValue")]
|
||||
public float min;
|
||||
public float max;
|
||||
public bool setOnStart;
|
||||
|
||||
public UnityEngine.UI.Slider.SliderEvent onSet;
|
||||
private void Start()
|
||||
{
|
||||
if (setOnStart) Set();
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
public void Set()
|
||||
{
|
||||
if (randomValue) onSet.Invoke(Random.Range(min, max));
|
||||
else onSet.Invoke(max);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c685dc280c550b9439031d8f0274667e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class vRemoveParent : MonoBehaviour
|
||||
{
|
||||
|
||||
public bool removeOnStart = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (removeOnStart)
|
||||
{
|
||||
RemoveParent();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveParentOfOtherTransform(Transform target)
|
||||
{
|
||||
target.SetParent(null);
|
||||
}
|
||||
public void RemoveParent()
|
||||
{
|
||||
transform.SetParent(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2af67e890060a8242ad5e94cffbb8eca
|
||||
timeCreated: 1542766729
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.Utils
|
||||
{
|
||||
[vClassHeader("Reset Transform", useHelpBox = true, helpBoxText = "Use this to Reset transformation values<b><color=red>\nPosition Zero\nRotation Zero\nScale One</color> </b>", openClose = false)]
|
||||
public class vResetTransform : vMonoBehaviour
|
||||
{
|
||||
public bool resetPositionOnStart;
|
||||
public bool resetRotationOnStart;
|
||||
public bool resetScaleOnStart;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (resetPositionOnStart) ResetPosition();
|
||||
if (resetRotationOnStart) ResetRotation();
|
||||
if (resetScaleOnStart) ResetScale();
|
||||
}
|
||||
|
||||
public void ResetRotation()
|
||||
{
|
||||
if (transform.parent)
|
||||
transform.localEulerAngles = Vector3.zero;
|
||||
else
|
||||
transform.eulerAngles = Vector3.zero;
|
||||
}
|
||||
public void ResetPosition()
|
||||
{
|
||||
if (transform.parent)
|
||||
transform.localPosition = Vector3.zero;
|
||||
else transform.position = Vector3.zero;
|
||||
}
|
||||
public void ResetScale()
|
||||
{
|
||||
transform.localScale = Vector3.one;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3cc860dd66d05d4586faca96f38ea24
|
||||
timeCreated: 1554935132
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
namespace Invector
|
||||
{
|
||||
public class vRotateObject : MonoBehaviour
|
||||
{
|
||||
public Vector3 rotationSpeed;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
transform.Rotate(rotationSpeed * Time.deltaTime, Space.Self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf7aa4aa2663f5347bca7af8c649ee23
|
||||
timeCreated: 1475024975
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,122 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[vClassHeader("Rotate To Target")]
|
||||
public class vRotateToTarget : vMonoBehaviour
|
||||
{
|
||||
public Transform targetTransform;
|
||||
[FormerlySerializedAs("angleRoot")]
|
||||
public Transform angleRootH;
|
||||
public Transform rotatorH;
|
||||
public Transform angleRootV;
|
||||
[FormerlySerializedAs("rotator")]
|
||||
public Transform rotatorV;
|
||||
|
||||
public bool rotateH;
|
||||
public bool rotateV;
|
||||
public float rotationSpeedInAngle;
|
||||
public float rotationSpeedOutAngle;
|
||||
[Range(0.0f, 180.0f)]
|
||||
public float maxAngleVertical = 60.0f;
|
||||
[Range(0.0f, 180.0f)]
|
||||
public float maxAngleHorizontal = 60.0f;
|
||||
[Range(0.0f, 180.0f)]
|
||||
public float angleToReachTarget = 45f;
|
||||
|
||||
public UnityEngine.Events.UnityEvent onEnterAngle;
|
||||
public UnityEngine.Events.UnityEvent onStayAngle;
|
||||
public UnityEngine.Events.UnityEvent onExitAngle;
|
||||
public bool targetIsInAngleRange { protected set; get; }
|
||||
protected float angleH;
|
||||
protected float angleV;
|
||||
protected virtual void Start()
|
||||
{
|
||||
if (angleRootH == null) angleRootH = transform;
|
||||
if (angleRootV == null) angleRootV = transform;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
if (!angleRootH || !rotatorV) return;
|
||||
Transform target = targetTransform;
|
||||
if (rotatorV)
|
||||
angleV = rotatorV.localEulerAngles.x;
|
||||
if (rotatorH)
|
||||
angleH = rotatorH.localEulerAngles.y;
|
||||
if (target)
|
||||
{
|
||||
Vector3 targetDirV = target.position - angleRootV.position;
|
||||
Vector3 targetDirH = target.position - angleRootH.position;
|
||||
float _targetAngleV = angleRootV.forward.AngleFormOtherDirection(targetDirV.normalized).x;
|
||||
float _targetAngleH = angleRootH.forward.AngleFormOtherDirection(targetDirH.normalized).y;
|
||||
|
||||
bool _isInAngle = Mathf.Abs(_targetAngleV) <= maxAngleVertical && Mathf.Abs(_targetAngleH) <= maxAngleHorizontal;
|
||||
|
||||
if (_isInAngle != targetIsInAngleRange)
|
||||
{
|
||||
if (_isInAngle) onEnterAngle.Invoke();
|
||||
else onExitAngle.Invoke();
|
||||
targetIsInAngleRange = _isInAngle;
|
||||
}
|
||||
if (targetIsInAngleRange)
|
||||
{
|
||||
onStayAngle.Invoke();
|
||||
|
||||
angleV = Mathf.LerpAngle(angleV, _targetAngleV, rotationSpeedInAngle * Time.deltaTime);
|
||||
|
||||
angleH = Mathf.LerpAngle(angleH, _targetAngleH, rotationSpeedInAngle * Time.deltaTime);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
angleV = Mathf.LerpAngle(angleV, 0, rotationSpeedOutAngle * Time.deltaTime);
|
||||
|
||||
angleH = Mathf.LerpAngle(angleH, 0, rotationSpeedOutAngle * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetIsInAngleRange)
|
||||
{
|
||||
onExitAngle.Invoke();
|
||||
targetIsInAngleRange = false;
|
||||
}
|
||||
if (rotatorV.localEulerAngles.magnitude > 0)
|
||||
{
|
||||
angleV = Mathf.LerpAngle(angleV, 0, rotationSpeedOutAngle * Time.deltaTime);
|
||||
angleH = Mathf.LerpAngle(angleH, 0, rotationSpeedOutAngle * Time.deltaTime);
|
||||
|
||||
}
|
||||
}
|
||||
if (rotateV && rotateV)
|
||||
{
|
||||
Vector3 eulerV = rotatorV.localEulerAngles;
|
||||
eulerV.x = angleV;
|
||||
rotatorV.localEulerAngles = eulerV;
|
||||
}
|
||||
|
||||
if (rotateH && rotatorH)
|
||||
{
|
||||
Vector3 eulerH = rotatorH.localEulerAngles;
|
||||
eulerH.y = angleH;
|
||||
rotatorH.localEulerAngles = eulerH;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SetTarget(Transform target)
|
||||
{
|
||||
targetTransform = target;
|
||||
}
|
||||
|
||||
public void ClearTarget()
|
||||
{
|
||||
targetTransform = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94fcc8a0dc8dcb347aa7138a7bd0e6bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
namespace Invector.Utils
|
||||
{
|
||||
public class vScaleControl : MonoBehaviour
|
||||
{
|
||||
|
||||
Vector3 targetScale;
|
||||
Vector3 defaultScale;
|
||||
private void Awake()
|
||||
{
|
||||
defaultScale = transform.localScale;
|
||||
targetScale = defaultScale;
|
||||
|
||||
}
|
||||
public float scaleX
|
||||
{
|
||||
set
|
||||
{
|
||||
targetScale.x = defaultScale.x * value;
|
||||
|
||||
transform.localScale = targetScale;
|
||||
}
|
||||
}
|
||||
public float scaleY
|
||||
{
|
||||
set
|
||||
{
|
||||
targetScale.y = defaultScale.y * value;
|
||||
|
||||
transform.localScale = targetScale;
|
||||
}
|
||||
}
|
||||
public float scaleZ
|
||||
{
|
||||
set
|
||||
{
|
||||
targetScale.z = defaultScale.z * value;
|
||||
|
||||
transform.localScale = targetScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8b55f679a287bb4f901c951eb9c14bc
|
||||
timeCreated: 1551586759
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
[System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = true)]
|
||||
public class vSelectableStringAttribute : PropertyAttribute
|
||||
{
|
||||
public string tittle;
|
||||
public string selectableText;
|
||||
public vSelectableStringAttribute(string tittle, string selectableText)
|
||||
{
|
||||
this.tittle = tittle;
|
||||
this.selectableText = selectableText;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 470bbee6779a2ed42ad6768dde195228
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
namespace Invector.Utils
|
||||
{
|
||||
public class vSetParent : MonoBehaviour
|
||||
{
|
||||
public void RemoveParent()
|
||||
{
|
||||
transform.parent = null;
|
||||
}
|
||||
|
||||
public void RemoveParent(Transform target)
|
||||
{
|
||||
target.parent = null;
|
||||
}
|
||||
|
||||
public void SetParent(Transform parent)
|
||||
{
|
||||
transform.parent = parent;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51eeb3c715390c14298a77f0c7326a89
|
||||
timeCreated: 1525377387
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using Invector.vCharacterController;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.Utils
|
||||
{
|
||||
public class vSetParentOfController : MonoBehaviour
|
||||
{
|
||||
[vHelpBox("Set this GameObject as parent of the Controller")]
|
||||
|
||||
private vThirdPersonController cc;
|
||||
|
||||
public UnityEngine.Events.UnityEvent onStart;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
cc = GetComponentInParent<vThirdPersonController>();
|
||||
transform.parent = cc.transform;
|
||||
|
||||
onStart.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d202ba2a7a19d04b8aca5b6f91494f3
|
||||
timeCreated: 1525377387
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector.Utils
|
||||
{
|
||||
[vClassHeader("Set Transform", openClose = false)]
|
||||
public class vSetTransform : vMonoBehaviour
|
||||
{
|
||||
public Transform targetPosition;
|
||||
|
||||
public void SetPosition(Transform _target)
|
||||
{
|
||||
_target.position = SelfTransform.position;
|
||||
}
|
||||
|
||||
public void SetRotation(Transform _target)
|
||||
{
|
||||
_target.rotation = SelfTransform.rotation;
|
||||
}
|
||||
|
||||
public void SetPositionAndRotation(Transform _target)
|
||||
{
|
||||
SetPosition(_target);
|
||||
SetRotation(_target);
|
||||
}
|
||||
|
||||
public Transform SelfTransform { get { return targetPosition ? targetPosition : transform; } }
|
||||
|
||||
public void SetPosition(Collider _target)
|
||||
{
|
||||
_target.transform.position = SelfTransform.position;
|
||||
}
|
||||
|
||||
public void SetRotation(Collider _target)
|
||||
{
|
||||
_target.transform.rotation = SelfTransform.rotation;
|
||||
}
|
||||
|
||||
public void SetPositionAndRotation(Collider _target)
|
||||
{
|
||||
SetPosition(_target);
|
||||
SetRotation(_target);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad048285527da9e4193c450b93b5e129
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Invector
|
||||
{
|
||||
[vClassHeader("Skybox Fade", helpBoxText = "A Skybox with Cubemap type is Required to use this Component", useHelpBox = true)]
|
||||
public class vSkyboxFade : vMonoBehaviour
|
||||
{
|
||||
public SkyboxFadeSettings defaultSkyboxSettings;
|
||||
public List<SkyboxFadeSettings> fadeSettings;
|
||||
|
||||
SkyboxFadeSettings currentFadeSettings;
|
||||
SkyboxFadeSettings lastFadeSettings;
|
||||
SkyboxFadeSettings targetFadeSettings;
|
||||
|
||||
Material skybox;
|
||||
bool exitRoutine;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
skybox = RenderSettings.skybox;
|
||||
lastFadeSettings = new SkyboxFadeSettings();
|
||||
//defaultSkyboxSettings = new SkyboxFadeSettings(skybox);
|
||||
currentFadeSettings = defaultSkyboxSettings.Copy();
|
||||
currentFadeSettings = new SkyboxFadeSettings(skybox);
|
||||
skybox.SetColor("_Tint", defaultSkyboxSettings.tint);
|
||||
skybox.SetFloat("_Exposure", defaultSkyboxSettings.exposure);
|
||||
skybox.SetFloat("_Rotation", defaultSkyboxSettings.rotation);
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
skybox.SetColor("_Tint", defaultSkyboxSettings.tint);
|
||||
skybox.SetFloat("_Exposure", defaultSkyboxSettings.exposure);
|
||||
skybox.SetFloat("_Rotation", defaultSkyboxSettings.rotation);
|
||||
}
|
||||
|
||||
public void Fade(string _fadeName)
|
||||
{
|
||||
targetFadeSettings = fadeSettings.Find(f => f.name.Equals(_fadeName));
|
||||
if (targetFadeSettings != null)
|
||||
{
|
||||
exitRoutine = true;
|
||||
StartCoroutine(FadeRoutine());
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeToDefault()
|
||||
{
|
||||
targetFadeSettings = defaultSkyboxSettings.Copy();
|
||||
exitRoutine = true;
|
||||
StartCoroutine(FadeRoutine());
|
||||
}
|
||||
|
||||
IEnumerator FadeRoutine()
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
exitRoutine = false;
|
||||
//defaultSkyboxSettings.curve = defaultCurve;
|
||||
//defaultSkyboxSettings.fadeTime = defaultFadeTime;
|
||||
lastFadeSettings.tint = currentFadeSettings.tint;
|
||||
lastFadeSettings.exposure = currentFadeSettings.exposure;
|
||||
lastFadeSettings.rotation = currentFadeSettings.rotation;
|
||||
float timer = 0;
|
||||
|
||||
if (!(lastFadeSettings.tint == targetFadeSettings.tint && lastFadeSettings.exposure == targetFadeSettings.exposure && targetFadeSettings.rotation == lastFadeSettings.rotation))
|
||||
{
|
||||
do
|
||||
{
|
||||
currentFadeSettings.tint = Color.Lerp(lastFadeSettings.tint, targetFadeSettings.tint, targetFadeSettings.curve.Evaluate(timer));
|
||||
currentFadeSettings.exposure = Mathf.Lerp(lastFadeSettings.exposure, targetFadeSettings.exposure, targetFadeSettings.curve.Evaluate(timer));
|
||||
currentFadeSettings.rotation = Mathf.Lerp(lastFadeSettings.rotation, targetFadeSettings.rotation, targetFadeSettings.curve.Evaluate(timer));
|
||||
|
||||
skybox.SetColor("_Tint", currentFadeSettings.tint);
|
||||
skybox.SetFloat("_Exposure", currentFadeSettings.exposure);
|
||||
skybox.SetFloat("_Rotation", currentFadeSettings.rotation);
|
||||
|
||||
yield return null;
|
||||
if (timer >= 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
timer += Time.fixedDeltaTime / targetFadeSettings.fadeTime;
|
||||
}
|
||||
while (!exitRoutine);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SkyboxFadeSettings
|
||||
{
|
||||
public string name = "My SkySettings";
|
||||
public AnimationCurve curve = AnimationCurve.Linear(0.0f, 0.0f, 1.0f, 1.0f);
|
||||
public float fadeTime = 1f;
|
||||
public Color tint = new Color(0.5f, 0.5f, 0.5f, 0.5f);
|
||||
[Range(0f, 8f)]
|
||||
public float exposure = 1f;
|
||||
[Range(0f, 360f)]
|
||||
public float rotation = 0f;
|
||||
|
||||
public SkyboxFadeSettings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public SkyboxFadeSettings(Material mat)
|
||||
{
|
||||
tint = mat.GetColor("_Tint");
|
||||
exposure = mat.GetFloat("_Exposure");
|
||||
rotation = mat.GetFloat("_Rotation");
|
||||
}
|
||||
|
||||
public void CopyMaterial(Material mat)
|
||||
{
|
||||
tint = mat.GetColor("_Tint");
|
||||
exposure = mat.GetFloat("_Exposure");
|
||||
rotation = mat.GetFloat("_Rotation");
|
||||
}
|
||||
|
||||
public SkyboxFadeSettings Copy()
|
||||
{
|
||||
var fadeSettings = new SkyboxFadeSettings();
|
||||
fadeSettings.curve = curve;
|
||||
fadeSettings.fadeTime = fadeTime;
|
||||
fadeSettings.tint = tint;
|
||||
fadeSettings.exposure = exposure;
|
||||
fadeSettings.rotation = rotation;
|
||||
|
||||
return fadeSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 566b9380399df6049af608844e406770
|
||||
timeCreated: 1527213602
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
namespace Invector
|
||||
{
|
||||
public class vSliderSizeControl : MonoBehaviour
|
||||
{
|
||||
public Slider slider;
|
||||
public RectTransform rectTransform;
|
||||
public float multipScale = 0.1f;
|
||||
float oldMaxValue;
|
||||
|
||||
void OnDrawGizmosSelected()
|
||||
{
|
||||
UpdateScale();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Invoke("UpdateScale", 0.1f);
|
||||
}
|
||||
|
||||
public void UpdateScale()
|
||||
{
|
||||
if (rectTransform && slider)
|
||||
{
|
||||
if (slider.maxValue != oldMaxValue)
|
||||
{
|
||||
var sizeDelta = rectTransform.sizeDelta;
|
||||
sizeDelta.x = slider.maxValue * multipScale;
|
||||
rectTransform.sizeDelta = sizeDelta;
|
||||
oldMaxValue = slider.maxValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f5523d2a00695b4ba1cfe2dc1e8e516
|
||||
timeCreated: 1544104515
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace Invector
|
||||
{
|
||||
public class vSpawnOnParticleCollision : MonoBehaviour
|
||||
{
|
||||
[vHelpBox("This component is used to spawn objects when particle collide with something\n")]
|
||||
public ParticleSystem part;
|
||||
public GameObject prefab;
|
||||
public List<ParticleCollisionEvent> collisionEvents = new List<ParticleCollisionEvent>();
|
||||
|
||||
Transform damageSender;
|
||||
[vHelpBox("When the prefab is a ObjectDamage you can use this properties to override the damage frequency and the damage value")]
|
||||
public bool overrideDamage;
|
||||
public float damageFrequeny;
|
||||
public vDamage damage;
|
||||
public void SetOverrideDamageSender(Transform sender)
|
||||
{
|
||||
damageSender = sender;
|
||||
}
|
||||
|
||||
protected virtual void OnParticleCollision(GameObject hit)
|
||||
{
|
||||
int numCollisionEvents = part.GetCollisionEvents(hit, collisionEvents);
|
||||
var intersection = collisionEvents[0].intersection;
|
||||
var normal = collisionEvents[0].normal;
|
||||
var go = Instantiate(prefab, intersection, Quaternion.LookRotation(normal), vObjectContainer.root);
|
||||
|
||||
if (damageSender && go.TryGetComponent(out vObjectDamage d))
|
||||
{
|
||||
d.SetOverrideDamageSender(damageSender);
|
||||
if (overrideDamage)
|
||||
{
|
||||
d.damage.damageValue = 0;
|
||||
d.onSendDamage.AddListener(OnSendDamage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected Dictionary<GameObject, DamageHandle> targetStorage = new Dictionary<GameObject, DamageHandle>();
|
||||
|
||||
protected class DamageHandle
|
||||
{
|
||||
public Transform target;
|
||||
public float damageFrequeny;
|
||||
float lastDamageTime;
|
||||
public bool canApplyDamage => lastDamageTime < Time.time;
|
||||
public void ApplyDamage(vDamage damage)
|
||||
{
|
||||
if (canApplyDamage)
|
||||
{
|
||||
lastDamageTime = Time.time + damageFrequeny;
|
||||
damage.receiver.gameObject.ApplyDamage(damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnSendDamage(vDamage damage)
|
||||
{
|
||||
if (!targetStorage.ContainsKey(damage.receiver.gameObject))
|
||||
{
|
||||
targetStorage.Add(damage.receiver.gameObject, new DamageHandle());
|
||||
}
|
||||
|
||||
if (targetStorage.TryGetValue(damage.receiver.gameObject, out DamageHandle handle))
|
||||
{
|
||||
handle.damageFrequeny = damageFrequeny;
|
||||
if (handle.canApplyDamage)
|
||||
{
|
||||
damage.damageValue = this.damage.damageValue;
|
||||
damage.damageType = this.damage.damageType;
|
||||
damage.reaction_id = this.damage.reaction_id;
|
||||
damage.recoil_id = this.damage.recoil_id;
|
||||
handle.ApplyDamage(damage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user