Skip to content
Snippets Groups Projects
Commit 9baedaf6 authored by Richard Marcus's avatar Richard Marcus
Browse files

SnapZone Prototype at root, always on top shader for point

parent c70c18d9
Branches
No related tags found
No related merge requests found
...@@ -41,6 +41,7 @@ PointFact AddPointFact(RaycastHit hit, int id) ...@@ -41,6 +41,7 @@ PointFact AddPointFact(RaycastHit hit, int id)
Facts.Insert(id, new PointFact Facts.Insert(id, new PointFact
{ {
Id = id, Id = id,
Point = hit.point, Point = hit.point,
Normal = hit.normal Normal = hit.normal
......
...@@ -33,10 +33,25 @@ void Update() ...@@ -33,10 +33,25 @@ void Update()
if(Physics.Raycast(ray, out Hit, 30f, layerMask)){ if(Physics.Raycast(ray, out Hit, 30f, layerMask)){
Debug.Log(Hit.transform.tag);
if (Hit.collider.transform.CompareTag("SnapZone"))
{
Hit.point = Hit.collider.transform.position;
Hit.normal = Vector3.up;
Debug.Log("boom");
CheckMouseButtons(true);
}
else
{
transform.position = Hit.point; transform.position = Hit.point;
transform.up = Hit.normal; transform.up = Hit.normal;
transform.position += .01f * Hit.normal; transform.position += .01f * Hit.normal;
CheckMouseButtons(ray); CheckMouseButtons();
}
} }
...@@ -51,7 +66,7 @@ void Update() ...@@ -51,7 +66,7 @@ void Update()
} }
//Check if left Mouse-Button was pressed and handle it //Check if left Mouse-Button was pressed and handle it
void CheckMouseButtons(Ray ray) void CheckMouseButtons(bool OnSnap=false)
{ {
if (Input.GetMouseButtonDown(0)) if (Input.GetMouseButtonDown(0))
...@@ -59,6 +74,7 @@ void CheckMouseButtons(Ray ray) ...@@ -59,6 +74,7 @@ void CheckMouseButtons(Ray ray)
if (EventSystem.current.IsPointerOverGameObject()) return; //this prevents rays from shooting through ui if (EventSystem.current.IsPointerOverGameObject()) return; //this prevents rays from shooting through ui
CommunicationEvents.TriggerEvent.Invoke(Hit); CommunicationEvents.TriggerEvent.Invoke(Hit);
if(OnSnap) Hit.collider.enabled = false;
} }
} }
......
fileFormatVersion: 2
guid: b543d9677cbde534ab69c0a229bfdb06
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
...@@ -8,12 +8,12 @@ Material: ...@@ -8,12 +8,12 @@ Material:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: PointMaterial m_Name: PointMaterial
m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 4800000, guid: 2649b895a4c22d649852a0ca4c825c74, type: 3}
m_ShaderKeywords: m_ShaderKeywords:
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0 m_DoubleSidedGI: 0
m_CustomRenderQueue: 4000 m_CustomRenderQueue: -1
stringTagMap: {} stringTagMap: {}
disabledShaderPasses: [] disabledShaderPasses: []
m_SavedProperties: m_SavedProperties:
...@@ -57,6 +57,7 @@ Material: ...@@ -57,6 +57,7 @@ Material:
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
m_Floats: m_Floats:
- _BumpScale: 1 - _BumpScale: 1
- _ColorMask: 15
- _Cutoff: 0.5 - _Cutoff: 0.5
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _DstBlend: 0 - _DstBlend: 0
...@@ -70,6 +71,11 @@ Material: ...@@ -70,6 +71,11 @@ Material:
- _SmoothnessTextureChannel: 0 - _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1 - _SpecularHighlights: 1
- _SrcBlend: 1 - _SrcBlend: 1
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UVSec: 0 - _UVSec: 0
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:
......
fileFormatVersion: 2
guid: 3356a4e49dc7a1f49a8ed203da5a847d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/AlwaysOnTop" {
Properties{
_MainTex("Font Texture", 2D) = "white" {}
_Color("Text Color", Color) = (1,1,1,1)
_StencilComp("Stencil Comparison", Float) = 8
_Stencil("Stencil ID", Float) = 0
_StencilOp("Stencil Operation", Float) = 0
_StencilWriteMask("Stencil Write Mask", Float) = 255
_StencilReadMask("Stencil Read Mask", Float) = 255
_ColorMask("Color Mask", Float) = 15
}
SubShader{
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
"PreviewType" = "Plane"
}
Stencil
{
Ref[_Stencil]
Comp[_StencilComp]
Pass[_StencilOp]
ReadMask[_StencilReadMask]
WriteMask[_StencilWriteMask]
}
Lighting Off
Cull Off
ZTest Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
ColorMask[_ColorMask]
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
sampler2D _MainTex;
uniform float4 _MainTex_ST;
uniform fixed4 _Color;
v2f vert(appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.color = v.color * _Color;
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
#ifdef UNITY_HALF_TEXEL_OFFSET
o.vertex.xy += (_ScreenParams.zw - 1.0)*float2(-1,1);
#endif
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 col = i.color;
col.a *= tex2D(_MainTex, i.texcoord).a;
clip(col.a - 0.01);
return col;
}
ENDCG
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 2649b895a4c22d649852a0ca4c825c74
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
...@@ -1410,6 +1410,50 @@ MonoBehaviour: ...@@ -1410,6 +1410,50 @@ MonoBehaviour:
m_OnClick: m_OnClick:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
--- !u!1 &1009368148
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1009368149}
- component: {fileID: 1009368150}
m_Layer: 0
m_Name: RootSnapZone
m_TagString: SnapZone
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1009368149
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1009368148}
m_LocalRotation: {x: -0, y: -0.030180298, z: 0.7032498, w: 0.710302}
m_LocalPosition: {x: -0.12, y: 0.48, z: 0.09}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1347135377}
m_RootOrder: 17
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!135 &1009368150
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1009368148}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 2
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &1017737548 --- !u!1 &1017737548
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -1812,6 +1856,12 @@ MonoBehaviour: ...@@ -1812,6 +1856,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 38927f5b66d24cc428e39ffa454b0bfb, type: 3} m_Script: {fileID: 11500000, guid: 38927f5b66d24cc428e39ffa454b0bfb, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
--- !u!4 &1347135377 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb,
type: 3}
m_PrefabInstance: {fileID: 154206643}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1351049950 --- !u!1 &1351049950
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
...@@ -6,6 +6,7 @@ TagManager: ...@@ -6,6 +6,7 @@ TagManager:
tags: tags:
- ToolModeDisplay - ToolModeDisplay
- Selectable - Selectable
- SnapZone
layers: layers:
- Default - Default
- TransparentFX - TransparentFX
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment