formatting
This commit is contained in:
@@ -0,0 +1 @@
|
||||
*.cs filter=tabify
|
||||
Executable
+370
@@ -0,0 +1,370 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1001 &3755469950790061681
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 8387739526954179449}
|
||||
m_Modifications:
|
||||
- target: {fileID: -7307756874029176930, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: Name
|
||||
value: Q
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -7307756874029176930, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: Orientation.x
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1824742176375353076, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Q
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 2.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -1.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
--- !u!1001 &6953158164962515518
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 8387739526954179449}
|
||||
m_Modifications:
|
||||
- target: {fileID: -7307756874029176930, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: Name
|
||||
value: A
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -7307756874029176930, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: IsInput
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -7307756874029176930, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: Orientation.x
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1824742176375353076, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: A
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -1.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8599692958760628507, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
|
||||
--- !u!1001 &7555383740349455498
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 347446582494478752, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: 200 Buffer gate
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1658337153186624383, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 2.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1658337153186624383, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalScale.y
|
||||
value: 2.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1658337153186624383, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 1.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1658337153186624383, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -1.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2169103976044701791, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_BodyType
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2169103976044701791, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_GravityScale
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_SpriteTilingProperty.pivot.y
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_SpriteTilingProperty.newSize.x
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_SpriteTilingProperty.newSize.y
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_SpriteTilingProperty.oldSize.x
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_SpriteTilingProperty.oldSize.y
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.size
|
||||
value: 13
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[0].x
|
||||
value: 2.46
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[0].y
|
||||
value: -1.61
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[1].x
|
||||
value: 2.61
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[1].y
|
||||
value: -1.52
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[2].x
|
||||
value: 2.61
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[2].y
|
||||
value: -1.49
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[3].x
|
||||
value: 2.6
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[3].y
|
||||
value: -1.4699999
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[4].x
|
||||
value: 2.35
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[4].y
|
||||
value: -1.3299999
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[5].x
|
||||
value: 0.55
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[5].y
|
||||
value: -0.32999998
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[6].x
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[6].y
|
||||
value: -0.32
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[7].x
|
||||
value: 0.48
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[7].y
|
||||
value: -0.34
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[8].x
|
||||
value: 0.48
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[8].y
|
||||
value: -2.6599998
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[9].x
|
||||
value: 0.48999998
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[9].y
|
||||
value: -2.6799998
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_SpriteTilingProperty.adaptiveTilingThreshold
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[10].x
|
||||
value: 0.52
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[10].y
|
||||
value: -2.6799998
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[11].x
|
||||
value: 0.57
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[11].y
|
||||
value: -2.6699998
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[12].x
|
||||
value: 0.75
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4542802031506979094, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Points.m_Paths.Array.data[0].Array.data[12].y
|
||||
value: -2.56
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9216698528057375618, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Size.x
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9216698528057375618, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Size.y
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9216698528057375618, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_Sprite
|
||||
value:
|
||||
objectReference: {fileID: 3286163911610860551, guid: 9b1c4145c6340064297ab349609dd56c, type: 3}
|
||||
- target: {fileID: 9216698528057375618, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_WasSpriteAssigned
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
--- !u!4 &8387739526954179449 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
m_PrefabInstance: {fileID: 7555383740349455498}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 368a8d7e21df7914f808163c111f710d
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,77 +4,77 @@ using UnityEngine;
|
||||
|
||||
namespace UntitledLogicGame
|
||||
{
|
||||
public class CameraManager : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
public class CameraManager : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
[Header("Zooming")]
|
||||
public int MinSize;
|
||||
public int MaxSize;
|
||||
public float ScrollSensitivity;
|
||||
[Header("Zooming")]
|
||||
public int MinSize;
|
||||
public int MaxSize;
|
||||
public float ScrollSensitivity;
|
||||
|
||||
[Header("Moving")]
|
||||
public Camera Camera101;
|
||||
[Header("Moving")]
|
||||
public Camera Camera101;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
#region Public Properties
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private Vector3 _startDragMousePos;
|
||||
private Vector3? _startDragPos;
|
||||
private Vector3 _startDragMousePos;
|
||||
private Vector3? _startDragPos;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
UpdateZoom();
|
||||
UpdateDrag();
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
UpdateZoom();
|
||||
UpdateDrag();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
private void UpdateZoom()
|
||||
{
|
||||
var size = Camera.main.orthographicSize;
|
||||
size -= Input.GetAxis("Mouse ScrollWheel") * ScrollSensitivity;
|
||||
size = Mathf.Clamp(size, MinSize, MaxSize);
|
||||
Camera.main.orthographicSize = size;
|
||||
Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, -size);
|
||||
}
|
||||
private void UpdateZoom()
|
||||
{
|
||||
var size = Camera.main.orthographicSize;
|
||||
size -= Input.GetAxis("Mouse ScrollWheel") * ScrollSensitivity;
|
||||
size = Mathf.Clamp(size, MinSize, MaxSize);
|
||||
Camera.main.orthographicSize = size;
|
||||
Camera.main.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, -size);
|
||||
}
|
||||
|
||||
private void UpdateDrag()
|
||||
{
|
||||
if (Input.GetMouseButton(2))
|
||||
{
|
||||
var mousePos = Camera101.ScreenToWorldPoint(Input.mousePosition);
|
||||
mousePos.z = 0f;
|
||||
private void UpdateDrag()
|
||||
{
|
||||
if (Input.GetMouseButton(2))
|
||||
{
|
||||
var mousePos = Camera101.ScreenToWorldPoint(Input.mousePosition);
|
||||
mousePos.z = 0f;
|
||||
|
||||
if (_startDragPos == null)
|
||||
{
|
||||
_startDragMousePos = mousePos;
|
||||
_startDragPos = Camera.main.transform.position;
|
||||
}
|
||||
if (_startDragPos == null)
|
||||
{
|
||||
_startDragMousePos = mousePos;
|
||||
_startDragPos = Camera.main.transform.position;
|
||||
}
|
||||
|
||||
Camera.main.transform.position = _startDragPos.Value - (mousePos - _startDragMousePos) * Camera.main.orthographicSize;
|
||||
}
|
||||
else if (_startDragPos != null)
|
||||
{
|
||||
_startDragPos = null;
|
||||
}
|
||||
}
|
||||
Camera.main.transform.position = _startDragPos.Value - (mousePos - _startDragMousePos) * Camera.main.orthographicSize;
|
||||
}
|
||||
else if (_startDragPos != null)
|
||||
{
|
||||
_startDragPos = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -5,31 +5,31 @@ using UnityEngine;
|
||||
|
||||
namespace UntitledLogicGame
|
||||
{
|
||||
//public class TODO : MonoBehaviour
|
||||
//{
|
||||
// #region Unity Properties
|
||||
//public class TODO : MonoBehaviour
|
||||
//{
|
||||
// #region Unity Properties
|
||||
|
||||
// #endregion
|
||||
// #endregion
|
||||
|
||||
// #region Public Properties
|
||||
// #region Public Properties
|
||||
|
||||
// #endregion
|
||||
// #endregion
|
||||
|
||||
// #region Private Properties
|
||||
// #region Private Properties
|
||||
|
||||
// #endregion
|
||||
// #endregion
|
||||
|
||||
// #region Unity Methods
|
||||
// #region Unity Methods
|
||||
|
||||
// #endregion
|
||||
// #endregion
|
||||
|
||||
// #region Public Methods
|
||||
// #region Public Methods
|
||||
|
||||
// #endregion
|
||||
// #endregion
|
||||
|
||||
// #region Private Methods
|
||||
// #region Private Methods
|
||||
|
||||
// #endregion
|
||||
//}
|
||||
// #endregion
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,80 +6,80 @@ using UntitledLogicGame.Workspace;
|
||||
|
||||
namespace UntitledLogicGame
|
||||
{
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
#region Static Properties
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
#region Static Properties
|
||||
|
||||
public static GameManager Instance {
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = FindObjectOfType<GameManager>();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
private static GameManager _instance;
|
||||
public static GameManager Instance {
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = FindObjectOfType<GameManager>();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
private static GameManager _instance;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Properties
|
||||
#region Unity Properties
|
||||
|
||||
[Header("Prefabs")]
|
||||
public Cable CablePrefab;
|
||||
[Header("Prefabs")]
|
||||
public Cable CablePrefab;
|
||||
|
||||
[Header("Groups")]
|
||||
public Transform GatesGroup;
|
||||
public Transform CablesGroup;
|
||||
[Header("Groups")]
|
||||
public Transform GatesGroup;
|
||||
public Transform CablesGroup;
|
||||
|
||||
[Header("Colors")]
|
||||
public Color DeadColor;
|
||||
public Color ActivatedColor;
|
||||
[Header("Colors")]
|
||||
public Color DeadColor;
|
||||
public Color ActivatedColor;
|
||||
|
||||
[Header("Gates")]
|
||||
public List<Gate> GatePrefabs;
|
||||
[Header("Gates")]
|
||||
public List<Gate> GatePrefabs;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
#region Public Properties
|
||||
|
||||
public Anchor CurrentAnchor { get; set; }
|
||||
public Gate CurrentGate { get; set; }
|
||||
public PointerManager PointerManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_pointerManager == null)
|
||||
_pointerManager = GetComponent<PointerManager>();
|
||||
return _pointerManager;
|
||||
}
|
||||
}
|
||||
public Anchor CurrentAnchor { get; set; }
|
||||
public Gate CurrentGate { get; set; }
|
||||
public PointerManager PointerManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_pointerManager == null)
|
||||
_pointerManager = GetComponent<PointerManager>();
|
||||
return _pointerManager;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private PointerManager _pointerManager;
|
||||
private PointerManager _pointerManager;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
public void CreateGate(Gate gatePrefab)
|
||||
{
|
||||
var gate = Instantiate(gatePrefab, GatesGroup);
|
||||
gate.transform.position = PointerManager.MousePos - gate.Box.transform.position;
|
||||
PointerManager.DragGate(gate, true);
|
||||
}
|
||||
public void CreateGate(Gate gatePrefab)
|
||||
{
|
||||
var gate = Instantiate(gatePrefab, GatesGroup);
|
||||
gate.transform.position = PointerManager.MousePos - gate.Box.transform.position;
|
||||
PointerManager.DragGate(gate, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
+191
-191
@@ -7,226 +7,226 @@ using UntitledLogicGame.Workspace;
|
||||
|
||||
namespace UntitledLogicGame
|
||||
{
|
||||
public class PointerManager : MonoBehaviour
|
||||
{
|
||||
#region Static Properties
|
||||
public class PointerManager : MonoBehaviour
|
||||
{
|
||||
#region Static Properties
|
||||
|
||||
public static PointerManager Instance => GameManager.Instance.PointerManager;
|
||||
public static PointerManager Instance => GameManager.Instance.PointerManager;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Properties
|
||||
#region Unity Properties
|
||||
|
||||
[Header("Click")]
|
||||
public float DoubleClickThreshold;
|
||||
public float DoubleClickDelay;
|
||||
[Header("Click")]
|
||||
public float DoubleClickThreshold;
|
||||
public float DoubleClickDelay;
|
||||
|
||||
[Header("Cursor")]
|
||||
public Texture2D DefaultCursor;
|
||||
public Texture2D PointerCursor;
|
||||
public Texture2D MoveCursor;
|
||||
[Header("Cursor")]
|
||||
public Texture2D DefaultCursor;
|
||||
public Texture2D PointerCursor;
|
||||
public Texture2D MoveCursor;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
#region Public Properties
|
||||
|
||||
public static Vector3 MousePos { get; set; }
|
||||
public bool Interacting => _currentCable != null || _currentGate != null;
|
||||
public bool MovingObject => _currentGate != null;
|
||||
public bool Clicking => Input.GetButton("Fire1");
|
||||
public bool DeleteOnRelease { get; set; }
|
||||
public static Vector3 MousePos { get; set; }
|
||||
public bool Interacting => _currentCable != null || _currentGate != null;
|
||||
public bool MovingObject => _currentGate != null;
|
||||
public bool Clicking => Input.GetButton("Fire1");
|
||||
public bool DeleteOnRelease { get; set; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private Cable _currentCable;
|
||||
private Gate _currentGate;
|
||||
private Vector3? _currentGateInitialPos;
|
||||
private Vector3 _currentGateDelta;
|
||||
private Texture2D _currentCursor;
|
||||
private float _clicked = 0f;
|
||||
private float _clicktime = 0f;
|
||||
private Cable _currentCable;
|
||||
private Gate _currentGate;
|
||||
private Vector3? _currentGateInitialPos;
|
||||
private Vector3 _currentGateDelta;
|
||||
private Texture2D _currentCursor;
|
||||
private float _clicked = 0f;
|
||||
private float _clicktime = 0f;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
UpdateMousePos();
|
||||
private void FixedUpdate()
|
||||
{
|
||||
UpdateMousePos();
|
||||
|
||||
if (Clicking)
|
||||
{
|
||||
UpdateDrag();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateDrop();
|
||||
}
|
||||
if (Clicking)
|
||||
{
|
||||
UpdateDrag();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateDrop();
|
||||
}
|
||||
|
||||
UpdateCursor();
|
||||
}
|
||||
UpdateCursor();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
public void DragGate(Gate gate, bool created)
|
||||
{
|
||||
_currentGate = gate;
|
||||
_currentGateDelta = MousePos - _currentGate.transform.position;
|
||||
_currentGateInitialPos = created ? (Vector3?)null : _currentGate.transform.position;
|
||||
foreach (var renderer in _currentGate.GetComponentsInChildren<SpriteRenderer>())
|
||||
{
|
||||
renderer.sortingLayerName = "moving";
|
||||
}
|
||||
}
|
||||
public void DragGate(Gate gate, bool created)
|
||||
{
|
||||
_currentGate = gate;
|
||||
_currentGateDelta = MousePos - _currentGate.transform.position;
|
||||
_currentGateInitialPos = created ? (Vector3?)null : _currentGate.transform.position;
|
||||
foreach (var renderer in _currentGate.GetComponentsInChildren<SpriteRenderer>())
|
||||
{
|
||||
renderer.sortingLayerName = "moving";
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestDelete()
|
||||
{
|
||||
if (_currentGate != null)
|
||||
{
|
||||
Destroy(_currentGate.gameObject);
|
||||
_currentGate = null;
|
||||
}
|
||||
}
|
||||
public void RequestDelete()
|
||||
{
|
||||
if (_currentGate != null)
|
||||
{
|
||||
Destroy(_currentGate.gameObject);
|
||||
_currentGate = null;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DoubleClick()
|
||||
{
|
||||
|
||||
if (Clicking)
|
||||
{
|
||||
_clicked += Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_clicked >= DoubleClickThreshold)
|
||||
{
|
||||
if(Time.time - _clicktime < DoubleClickDelay)
|
||||
{
|
||||
_clicked = 0f;
|
||||
_clicktime = 0f;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_clicktime = Time.time;
|
||||
}
|
||||
}
|
||||
_clicked = 0f;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool DoubleClick()
|
||||
{
|
||||
|
||||
if (Clicking)
|
||||
{
|
||||
_clicked += Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_clicked >= DoubleClickThreshold)
|
||||
{
|
||||
if(Time.time - _clicktime < DoubleClickDelay)
|
||||
{
|
||||
_clicked = 0f;
|
||||
_clicktime = 0f;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_clicktime = Time.time;
|
||||
}
|
||||
}
|
||||
_clicked = 0f;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
private static void UpdateMousePos()
|
||||
{
|
||||
var mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
mousePos.z = 0f;
|
||||
MousePos = mousePos;
|
||||
}
|
||||
private static void UpdateMousePos()
|
||||
{
|
||||
var mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
mousePos.z = 0f;
|
||||
MousePos = mousePos;
|
||||
}
|
||||
|
||||
private void UpdateCursor()
|
||||
{
|
||||
var cursor = DefaultCursor;
|
||||
var position = Vector2.zero;
|
||||
private void UpdateCursor()
|
||||
{
|
||||
var cursor = DefaultCursor;
|
||||
var position = Vector2.zero;
|
||||
|
||||
if (!Interacting && GameManager.Instance.CurrentAnchor != null || Interacting && _currentCable != null)
|
||||
{
|
||||
cursor = PointerCursor;
|
||||
position = new Vector2(cursor.width / 2f, 0f);
|
||||
}
|
||||
else if (!Interacting && GameManager.Instance.CurrentGate != null || Interacting && _currentGate != null)
|
||||
{
|
||||
cursor = MoveCursor;
|
||||
position = new Vector2(cursor.width / 2f, cursor.height / 2f);
|
||||
}
|
||||
if (!Interacting && GameManager.Instance.CurrentAnchor != null || Interacting && _currentCable != null)
|
||||
{
|
||||
cursor = PointerCursor;
|
||||
position = new Vector2(cursor.width / 2f, 0f);
|
||||
}
|
||||
else if (!Interacting && GameManager.Instance.CurrentGate != null || Interacting && _currentGate != null)
|
||||
{
|
||||
cursor = MoveCursor;
|
||||
position = new Vector2(cursor.width / 2f, cursor.height / 2f);
|
||||
}
|
||||
|
||||
if(_currentCursor != cursor)
|
||||
{
|
||||
//TODO Invalid texture used for cursor - check importer settings or texture creation. Texture must be RGBA32, readable, have alphaIsTransparency enabled and have no mip chain.
|
||||
Cursor.SetCursor(cursor, position, CursorMode.Auto);
|
||||
_currentCursor = cursor;
|
||||
}
|
||||
}
|
||||
if(_currentCursor != cursor)
|
||||
{
|
||||
//TODO Invalid texture used for cursor - check importer settings or texture creation. Texture must be RGBA32, readable, have alphaIsTransparency enabled and have no mip chain.
|
||||
Cursor.SetCursor(cursor, position, CursorMode.Auto);
|
||||
_currentCursor = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDrag()
|
||||
{
|
||||
if (_currentCable != null) // Dragging cable
|
||||
{
|
||||
_currentCable.FallbackEndPos = MousePos;
|
||||
}
|
||||
else if (_currentGate != null) // Dragging gate
|
||||
{
|
||||
_currentGate.transform.position = MousePos - _currentGateDelta;
|
||||
}
|
||||
else if (GameManager.Instance.CurrentAnchor != null) // Dragging new cable
|
||||
{
|
||||
_currentCable = Instantiate(GameManager.Instance.CablePrefab, GameManager.Instance.CablesGroup, true);
|
||||
_currentCable.StartAnchor = GameManager.Instance.CurrentAnchor;
|
||||
_currentCable.FallbackEndPos = MousePos;
|
||||
}
|
||||
else if (GameManager.Instance.CurrentGate != null) // Dragging new gate
|
||||
{
|
||||
DragGate(GameManager.Instance.CurrentGate, false);
|
||||
}
|
||||
}
|
||||
private void UpdateDrag()
|
||||
{
|
||||
if (_currentCable != null) // Dragging cable
|
||||
{
|
||||
_currentCable.FallbackEndPos = MousePos;
|
||||
}
|
||||
else if (_currentGate != null) // Dragging gate
|
||||
{
|
||||
_currentGate.transform.position = MousePos - _currentGateDelta;
|
||||
}
|
||||
else if (GameManager.Instance.CurrentAnchor != null) // Dragging new cable
|
||||
{
|
||||
_currentCable = Instantiate(GameManager.Instance.CablePrefab, GameManager.Instance.CablesGroup, true);
|
||||
_currentCable.StartAnchor = GameManager.Instance.CurrentAnchor;
|
||||
_currentCable.FallbackEndPos = MousePos;
|
||||
}
|
||||
else if (GameManager.Instance.CurrentGate != null) // Dragging new gate
|
||||
{
|
||||
DragGate(GameManager.Instance.CurrentGate, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDrop()
|
||||
{
|
||||
if (_currentCable != null) // Dropping cable
|
||||
{
|
||||
if (GameManager.Instance.CurrentAnchor == null || _currentCable.StartAnchor.IsInput == GameManager.Instance.CurrentAnchor.IsInput)
|
||||
{
|
||||
Destroy(_currentCable.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentCable.EndAnchor = GameManager.Instance.CurrentAnchor;
|
||||
}
|
||||
_currentCable = null;
|
||||
}
|
||||
else if (_currentGate != null) // Dropping gate
|
||||
{
|
||||
if (DeleteOnRelease)
|
||||
{
|
||||
Destroy(_currentGate.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var renderer in _currentGate.GetComponentsInChildren<SpriteRenderer>())
|
||||
{
|
||||
renderer.sortingLayerName = "default";
|
||||
}
|
||||
_currentGate.transform.position = _currentGate.transform.position.Round();
|
||||
var currentBox = _currentGate.Box;
|
||||
if (FindObjectsOfType<Gate>()
|
||||
.Where(g => !g.Equals(_currentGate))
|
||||
.Select(g => g.Box)
|
||||
.Any(b => currentBox.IsTouching(b)))
|
||||
{
|
||||
// Collision with another gate
|
||||
if (_currentGateInitialPos == null)
|
||||
{
|
||||
Destroy(_currentGate.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentGate.transform.position = _currentGateInitialPos.Value; // Reset pos
|
||||
}
|
||||
}
|
||||
}
|
||||
_currentGate = null;
|
||||
DeleteOnRelease = false;
|
||||
}
|
||||
}
|
||||
private void UpdateDrop()
|
||||
{
|
||||
if (_currentCable != null) // Dropping cable
|
||||
{
|
||||
if (GameManager.Instance.CurrentAnchor == null || _currentCable.StartAnchor.IsInput == GameManager.Instance.CurrentAnchor.IsInput)
|
||||
{
|
||||
Destroy(_currentCable.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentCable.EndAnchor = GameManager.Instance.CurrentAnchor;
|
||||
}
|
||||
_currentCable = null;
|
||||
}
|
||||
else if (_currentGate != null) // Dropping gate
|
||||
{
|
||||
if (DeleteOnRelease)
|
||||
{
|
||||
Destroy(_currentGate.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var renderer in _currentGate.GetComponentsInChildren<SpriteRenderer>())
|
||||
{
|
||||
renderer.sortingLayerName = "default";
|
||||
}
|
||||
_currentGate.transform.position = _currentGate.transform.position.Round();
|
||||
var currentBox = _currentGate.Box;
|
||||
if (FindObjectsOfType<Gate>()
|
||||
.Where(g => !g.Equals(_currentGate))
|
||||
.Select(g => g.Box)
|
||||
.Any(b => currentBox.IsTouching(b)))
|
||||
{
|
||||
// Collision with another gate
|
||||
if (_currentGateInitialPos == null)
|
||||
{
|
||||
Destroy(_currentGate.gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentGate.transform.position = _currentGateInitialPos.Value; // Reset pos
|
||||
}
|
||||
}
|
||||
}
|
||||
_currentGate = null;
|
||||
DeleteOnRelease = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,20 +6,20 @@ using UnityEngine.EventSystems;
|
||||
|
||||
namespace UntitledLogicGame.UI
|
||||
{
|
||||
public class UIDelete : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
public class UIDelete : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
public SVGImage closedImage;
|
||||
public SVGImage openImage;
|
||||
public SVGImage openImage;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
#region Public Properties
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private SVGImage Image
|
||||
{
|
||||
@@ -31,23 +31,23 @@ namespace UntitledLogicGame.UI
|
||||
}
|
||||
}
|
||||
|
||||
private SVGImage _image;
|
||||
private SVGImage _image;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
Image.sprite = openImage.sprite;
|
||||
PointerManager.Instance.DeleteOnRelease = true;
|
||||
}
|
||||
PointerManager.Instance.DeleteOnRelease = true;
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
Image.sprite = closedImage.sprite;
|
||||
PointerManager.Instance.DeleteOnRelease = false;
|
||||
}
|
||||
PointerManager.Instance.DeleteOnRelease = false;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
|
||||
@@ -34,18 +34,18 @@ namespace UntitledLogicGame.UI
|
||||
|
||||
#region Private Properties
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -7,16 +7,16 @@ using UntitledLogicGame.Workspace.Gates;
|
||||
|
||||
namespace UntitledLogicGame.UI
|
||||
{
|
||||
public class UIManager : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
public class UIManager : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
[Header("Components")]
|
||||
public GameObject GateBar;
|
||||
public GameObject MovingBar;
|
||||
[Header("Components")]
|
||||
public GameObject GateBar;
|
||||
public GameObject MovingBar;
|
||||
|
||||
[Header("Prefabs")]
|
||||
public UIGate UIGatePrefab;
|
||||
[Header("Prefabs")]
|
||||
public UIGate UIGatePrefab;
|
||||
public UIFolder UIFolderPrefab;
|
||||
|
||||
#endregion
|
||||
@@ -33,11 +33,11 @@ namespace UntitledLogicGame.UI
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private bool _lastMouseInteracting;
|
||||
private bool _lastMouseInteracting;
|
||||
private GateCategory _gateBarState;
|
||||
private Dictionary<GateCategory, GameObject> _gateBarSateList;
|
||||
|
||||
@@ -46,35 +46,35 @@ namespace UntitledLogicGame.UI
|
||||
#region Unity Methods
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
yield return new WaitUntil(() => GameManager.Instance != null);
|
||||
{
|
||||
yield return new WaitUntil(() => GameManager.Instance != null);
|
||||
CreateGateBar();
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
UpdateUI();
|
||||
private void FixedUpdate()
|
||||
{
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
private void UpdateUI()
|
||||
{
|
||||
if (PointerManager.Instance.Interacting != _lastMouseInteracting)
|
||||
{
|
||||
//TODO animate go down
|
||||
GateBar.SetActive(!PointerManager.Instance.Interacting);
|
||||
MovingBar.SetActive(PointerManager.Instance.MovingObject);
|
||||
_lastMouseInteracting = PointerManager.Instance.Interacting;
|
||||
}
|
||||
}
|
||||
private void UpdateUI()
|
||||
{
|
||||
if (PointerManager.Instance.Interacting != _lastMouseInteracting)
|
||||
{
|
||||
//TODO animate go down
|
||||
GateBar.SetActive(!PointerManager.Instance.Interacting);
|
||||
MovingBar.SetActive(PointerManager.Instance.MovingObject);
|
||||
_lastMouseInteracting = PointerManager.Instance.Interacting;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateGateBar()
|
||||
{
|
||||
@@ -144,6 +144,6 @@ namespace UntitledLogicGame.UI
|
||||
_gateBarSateList[category].SetActive(category == GateBarState);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using UnityEngine.EventSystems;
|
||||
|
||||
namespace UntitledLogicGame.UI
|
||||
{
|
||||
public class UIToolbarButton : MonoBehaviour, IPointerDownHandler
|
||||
public class UIToolbarButton : MonoBehaviour, IPointerDownHandler
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
|
||||
+40
-40
@@ -6,57 +6,57 @@ using Random = UnityEngine.Random;
|
||||
|
||||
namespace UntitledLogicGame
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
#region String Utils
|
||||
public static class Utils
|
||||
{
|
||||
#region String Utils
|
||||
|
||||
public static string RandomString(int length)
|
||||
{
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
return new string(Enumerable.Repeat(chars, length)
|
||||
.Select(s => s[Random.Range(0, s.Length)]).ToArray());
|
||||
}
|
||||
public static string RandomString(int length)
|
||||
{
|
||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
return new string(Enumerable.Repeat(chars, length)
|
||||
.Select(s => s[Random.Range(0, s.Length)]).ToArray());
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Bool Utils
|
||||
#region Bool Utils
|
||||
|
||||
public static bool[][] AllBoolArrayValues(int length)
|
||||
{
|
||||
public static bool[][] AllBoolArrayValues(int length)
|
||||
{
|
||||
if (length == 0)
|
||||
return new bool[0][];
|
||||
var count = (int)Math.Pow(2, length);
|
||||
return new ArrayList[count].Select((v, i) => i.ToBoolArray(length)).ToArray();
|
||||
}
|
||||
var count = (int)Math.Pow(2, length);
|
||||
return new ArrayList[count].Select((v, i) => i.ToBoolArray(length)).ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Utils
|
||||
#region Unity Utils
|
||||
|
||||
public static void RandomName(string prefix, GameObject obj)
|
||||
{
|
||||
obj.name = $"{prefix}_{RandomString(5)}";
|
||||
}
|
||||
public static void RandomName(string prefix, GameObject obj)
|
||||
{
|
||||
obj.name = $"{prefix}_{RandomString(5)}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
public static bool[] ToBoolArray(this int value, int length)
|
||||
{
|
||||
var str = Convert.ToString(value, 2).PadLeft(length, '0');
|
||||
return str.Select((x) => x == '1').ToArray();
|
||||
}
|
||||
public static class Extensions
|
||||
{
|
||||
public static bool[] ToBoolArray(this int value, int length)
|
||||
{
|
||||
var str = Convert.ToString(value, 2).PadLeft(length, '0');
|
||||
return str.Select((x) => x == '1').ToArray();
|
||||
}
|
||||
|
||||
public static int ToInt(this bool[] array)
|
||||
{
|
||||
return array.Select((v, i) => (v ? 1 : 0) << (array.Length - i - 1)).Sum();
|
||||
}
|
||||
public static int ToInt(this bool[] array)
|
||||
{
|
||||
return array.Select((v, i) => (v ? 1 : 0) << (array.Length - i - 1)).Sum();
|
||||
}
|
||||
|
||||
public static Vector3 Round(this Vector3 v)
|
||||
{
|
||||
return new Vector3(Mathf.Round(v.x), Mathf.Round(v.y), Mathf.Round(v.z));
|
||||
}
|
||||
}
|
||||
public static Vector3 Round(this Vector3 v)
|
||||
{
|
||||
return new Vector3(Mathf.Round(v.x), Mathf.Round(v.y), Mathf.Round(v.z));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,116 +5,116 @@ using UnityEngine;
|
||||
|
||||
namespace UntitledLogicGame.Workspace
|
||||
{
|
||||
public class Anchor : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
public class Anchor : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
public string Name;
|
||||
public bool IsInput;
|
||||
public float ScaleIncrease;
|
||||
public Vector2 Orientation;
|
||||
public string Name;
|
||||
public bool IsInput;
|
||||
public float ScaleIncrease;
|
||||
public Vector2 Orientation;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
#region Public Properties
|
||||
|
||||
public List<Cable> Cables { get; set; }
|
||||
public Gate Gate { get; set; }
|
||||
public bool Activated
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsInput)
|
||||
return Cables.Count > 0 && Cables.First().Activated;
|
||||
else
|
||||
return _activated;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!IsInput)
|
||||
_activated = value;
|
||||
}
|
||||
}
|
||||
public bool Hovering { get; internal set; }
|
||||
public List<Cable> Cables { get; set; }
|
||||
public Gate Gate { get; set; }
|
||||
public bool Activated
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsInput)
|
||||
return Cables.Count > 0 && Cables.First().Activated;
|
||||
else
|
||||
return _activated;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!IsInput)
|
||||
_activated = value;
|
||||
}
|
||||
}
|
||||
public bool Hovering { get; internal set; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private Vector3 _scale;
|
||||
private SpriteRenderer _sprite;
|
||||
private bool _activated;
|
||||
private bool? _lastActivated;
|
||||
private Vector3 _scale;
|
||||
private SpriteRenderer _sprite;
|
||||
private bool _activated;
|
||||
private bool? _lastActivated;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
Gate = GetComponentInParent<Gate>();
|
||||
Utils.RandomName($"{Gate.GateType}_{Name}", gameObject);
|
||||
_scale = transform.localScale;
|
||||
_sprite = GetComponent<SpriteRenderer>();
|
||||
Cables = new List<Cable>();
|
||||
Orientation = Orientation.normalized;
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
Gate = GetComponentInParent<Gate>();
|
||||
Utils.RandomName($"{Gate.GateType}_{Name}", gameObject);
|
||||
_scale = transform.localScale;
|
||||
_sprite = GetComponent<SpriteRenderer>();
|
||||
Cables = new List<Cable>();
|
||||
Orientation = Orientation.normalized;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
UpdateState();
|
||||
}
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
private void OnMouseEnter()
|
||||
{
|
||||
transform.localScale = _scale * ScaleIncrease;
|
||||
GameManager.Instance.CurrentAnchor = this;
|
||||
Hovering = true;
|
||||
}
|
||||
private void OnMouseEnter()
|
||||
{
|
||||
transform.localScale = _scale * ScaleIncrease;
|
||||
GameManager.Instance.CurrentAnchor = this;
|
||||
Hovering = true;
|
||||
}
|
||||
|
||||
private void OnMouseExit()
|
||||
{
|
||||
transform.localScale = _scale;
|
||||
if (Equals(GameManager.Instance.CurrentAnchor))
|
||||
GameManager.Instance.CurrentAnchor = null;
|
||||
Hovering = false;
|
||||
}
|
||||
private void OnMouseExit()
|
||||
{
|
||||
transform.localScale = _scale;
|
||||
if (Equals(GameManager.Instance.CurrentAnchor))
|
||||
GameManager.Instance.CurrentAnchor = null;
|
||||
Hovering = false;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
foreach(var cable in Cables)
|
||||
{
|
||||
Destroy(cable.gameObject);
|
||||
}
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
foreach(var cable in Cables)
|
||||
{
|
||||
Destroy(cable.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
public bool HasInputAnchor(Anchor target)
|
||||
{
|
||||
if (IsInput)
|
||||
return Cables.Any(c => c.HasInputAnchor(target));
|
||||
else
|
||||
return Gate.HasInputAnchor(target);
|
||||
}
|
||||
public bool HasInputAnchor(Anchor target)
|
||||
{
|
||||
if (IsInput)
|
||||
return Cables.Any(c => c.HasInputAnchor(target));
|
||||
else
|
||||
return Gate.HasInputAnchor(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
private void UpdateState()
|
||||
{
|
||||
if (_lastActivated == null || _lastActivated != Activated)
|
||||
{
|
||||
_sprite.color = Activated ? GameManager.Instance.ActivatedColor : GameManager.Instance.DeadColor;
|
||||
_lastActivated = Activated;
|
||||
}
|
||||
}
|
||||
private void UpdateState()
|
||||
{
|
||||
if (_lastActivated == null || _lastActivated != Activated)
|
||||
{
|
||||
_sprite.color = Activated ? GameManager.Instance.ActivatedColor : GameManager.Instance.DeadColor;
|
||||
_lastActivated = Activated;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+153
-153
@@ -5,183 +5,183 @@ using UnityEngine;
|
||||
|
||||
namespace UntitledLogicGame.Workspace
|
||||
{
|
||||
public class Cable : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
public class Cable : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
#region Public Properties
|
||||
|
||||
public Anchor StartAnchor
|
||||
{
|
||||
get => _startAnchor;
|
||||
set
|
||||
{
|
||||
_startAnchor = value;
|
||||
if (value.IsInput)
|
||||
{
|
||||
if (value.Cables.Count > 0)
|
||||
Destroy(value.Cables.First().gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
public Anchor EndAnchor
|
||||
{
|
||||
get => _endAnchor;
|
||||
set
|
||||
{
|
||||
if (!value.IsInput)
|
||||
{
|
||||
_endAnchor = StartAnchor;
|
||||
StartAnchor = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_endAnchor = value;
|
||||
}
|
||||
public Anchor StartAnchor
|
||||
{
|
||||
get => _startAnchor;
|
||||
set
|
||||
{
|
||||
_startAnchor = value;
|
||||
if (value.IsInput)
|
||||
{
|
||||
if (value.Cables.Count > 0)
|
||||
Destroy(value.Cables.First().gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
public Anchor EndAnchor
|
||||
{
|
||||
get => _endAnchor;
|
||||
set
|
||||
{
|
||||
if (!value.IsInput)
|
||||
{
|
||||
_endAnchor = StartAnchor;
|
||||
StartAnchor = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_endAnchor = value;
|
||||
}
|
||||
|
||||
if (StartAnchor.HasInputAnchor(EndAnchor))
|
||||
{
|
||||
// Loop detected
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartAnchor.Cables.Add(this);
|
||||
if (EndAnchor.Cables.Count > 0)
|
||||
Destroy(EndAnchor.Cables.First().gameObject);
|
||||
EndAnchor.Cables = new List<Cable> { this };
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool Activated => StartAnchor != null && !StartAnchor.IsInput && StartAnchor.Activated;
|
||||
public Vector3 FallbackEndPos { get; set; }
|
||||
if (StartAnchor.HasInputAnchor(EndAnchor))
|
||||
{
|
||||
// Loop detected
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartAnchor.Cables.Add(this);
|
||||
if (EndAnchor.Cables.Count > 0)
|
||||
Destroy(EndAnchor.Cables.First().gameObject);
|
||||
EndAnchor.Cables = new List<Cable> { this };
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool Activated => StartAnchor != null && !StartAnchor.IsInput && StartAnchor.Activated;
|
||||
public Vector3 FallbackEndPos { get; set; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private Vector3 _lastStartPos;
|
||||
private Vector3 _lastEndPos;
|
||||
private Anchor _startAnchor;
|
||||
private Anchor _endAnchor;
|
||||
private LineRenderer _line;
|
||||
private bool? _lastActivated;
|
||||
private Vector3 _lastStartPos;
|
||||
private Vector3 _lastEndPos;
|
||||
private Anchor _startAnchor;
|
||||
private Anchor _endAnchor;
|
||||
private LineRenderer _line;
|
||||
private bool? _lastActivated;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
_line = GetComponent<LineRenderer>();
|
||||
Utils.RandomName("Cable", gameObject);
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
_line = GetComponent<LineRenderer>();
|
||||
Utils.RandomName("Cable", gameObject);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
UpdateColor();
|
||||
UpdateLine();
|
||||
}
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
UpdateColor();
|
||||
UpdateLine();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if(StartAnchor != null)
|
||||
StartAnchor.Cables.Remove(this);
|
||||
if (EndAnchor != null)
|
||||
EndAnchor.Cables.Remove(this);
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
if(StartAnchor != null)
|
||||
StartAnchor.Cables.Remove(this);
|
||||
if (EndAnchor != null)
|
||||
EndAnchor.Cables.Remove(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
public bool HasInputAnchor(Anchor target)
|
||||
{
|
||||
return StartAnchor.HasInputAnchor(target);
|
||||
}
|
||||
public bool HasInputAnchor(Anchor target)
|
||||
{
|
||||
return StartAnchor.HasInputAnchor(target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
private void UpdateColor()
|
||||
{
|
||||
if (_lastActivated == null || _lastActivated != Activated)
|
||||
{
|
||||
_line.startColor = Activated ? GameManager.Instance.ActivatedColor : GameManager.Instance.DeadColor;
|
||||
_line.endColor = Activated ? GameManager.Instance.ActivatedColor : GameManager.Instance.DeadColor;
|
||||
_lastActivated = Activated;
|
||||
}
|
||||
}
|
||||
private void UpdateColor()
|
||||
{
|
||||
if (_lastActivated == null || _lastActivated != Activated)
|
||||
{
|
||||
_line.startColor = Activated ? GameManager.Instance.ActivatedColor : GameManager.Instance.DeadColor;
|
||||
_line.endColor = Activated ? GameManager.Instance.ActivatedColor : GameManager.Instance.DeadColor;
|
||||
_lastActivated = Activated;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateLine()
|
||||
{
|
||||
if (StartAnchor != null)
|
||||
{
|
||||
var startPos = StartAnchor.transform.position;
|
||||
var endPos = EndAnchor == null ? FallbackEndPos : EndAnchor.transform.position;
|
||||
private void UpdateLine()
|
||||
{
|
||||
if (StartAnchor != null)
|
||||
{
|
||||
var startPos = StartAnchor.transform.position;
|
||||
var endPos = EndAnchor == null ? FallbackEndPos : EndAnchor.transform.position;
|
||||
|
||||
if (startPos != _lastStartPos || endPos != _lastEndPos)
|
||||
{
|
||||
if (EndAnchor == null)
|
||||
{
|
||||
_line.positionCount = 2;
|
||||
_line.SetPosition(0, startPos);
|
||||
_line.SetPosition(1, endPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
var startOr = StartAnchor.Orientation;
|
||||
var endOr = StartAnchor.Orientation;
|
||||
if (startPos != _lastStartPos || endPos != _lastEndPos)
|
||||
{
|
||||
if (EndAnchor == null)
|
||||
{
|
||||
_line.positionCount = 2;
|
||||
_line.SetPosition(0, startPos);
|
||||
_line.SetPosition(1, endPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
var startOr = StartAnchor.Orientation;
|
||||
var endOr = StartAnchor.Orientation;
|
||||
|
||||
_line.positionCount = 4;
|
||||
_line.SetPosition(0, startPos);
|
||||
_line.positionCount = 4;
|
||||
_line.SetPosition(0, startPos);
|
||||
|
||||
if (Mathf.Abs(startOr.x) > 0)
|
||||
{
|
||||
if (Mathf.Abs(endOr.x) > 0)
|
||||
{
|
||||
var middle = (startPos.x + endPos.x) / 2;
|
||||
_line.SetPosition(1, new Vector3(middle, startPos.y, startPos.z));
|
||||
_line.SetPosition(2, new Vector3(middle, endPos.y, startPos.z));
|
||||
}
|
||||
else
|
||||
{
|
||||
_line.SetPosition(1, new Vector3(startPos.x, endPos.y, startPos.z));
|
||||
_line.SetPosition(2, new Vector3(startPos.x, endPos.y, startPos.z));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Mathf.Abs(endOr.x) > 0)
|
||||
{
|
||||
var middle = (startPos.y + endPos.y) / 2;
|
||||
_line.SetPosition(1, new Vector3(startPos.x, middle, startPos.z));
|
||||
_line.SetPosition(2, new Vector3(endPos.x, middle, startPos.z));
|
||||
}
|
||||
else
|
||||
{
|
||||
_line.SetPosition(1, new Vector3(endPos.x, startPos.y, startPos.z));
|
||||
_line.SetPosition(2, new Vector3(endPos.x, startPos.y, startPos.z));
|
||||
}
|
||||
}
|
||||
if (Mathf.Abs(startOr.x) > 0)
|
||||
{
|
||||
if (Mathf.Abs(endOr.x) > 0)
|
||||
{
|
||||
var middle = (startPos.x + endPos.x) / 2;
|
||||
_line.SetPosition(1, new Vector3(middle, startPos.y, startPos.z));
|
||||
_line.SetPosition(2, new Vector3(middle, endPos.y, startPos.z));
|
||||
}
|
||||
else
|
||||
{
|
||||
_line.SetPosition(1, new Vector3(startPos.x, endPos.y, startPos.z));
|
||||
_line.SetPosition(2, new Vector3(startPos.x, endPos.y, startPos.z));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Mathf.Abs(endOr.x) > 0)
|
||||
{
|
||||
var middle = (startPos.y + endPos.y) / 2;
|
||||
_line.SetPosition(1, new Vector3(startPos.x, middle, startPos.z));
|
||||
_line.SetPosition(2, new Vector3(endPos.x, middle, startPos.z));
|
||||
}
|
||||
else
|
||||
{
|
||||
_line.SetPosition(1, new Vector3(endPos.x, startPos.y, startPos.z));
|
||||
_line.SetPosition(2, new Vector3(endPos.x, startPos.y, startPos.z));
|
||||
}
|
||||
}
|
||||
|
||||
_line.SetPosition(3, endPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_line.positionCount = 0;
|
||||
}
|
||||
}
|
||||
_line.SetPosition(3, endPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_line.positionCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,106 +6,106 @@ using UntitledLogicGame.Workspace.Gates;
|
||||
|
||||
namespace UntitledLogicGame.Workspace
|
||||
{
|
||||
public class Gate : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
public class Gate : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
public GateType GateType;
|
||||
public GateType GateType;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
#region Public Properties
|
||||
|
||||
public IEnumerable<Anchor> Anchors
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_anchors == null)
|
||||
_anchors = GetComponentsInChildren<Anchor>().ToList();
|
||||
return _anchors;
|
||||
}
|
||||
}
|
||||
public IEnumerable<Anchor> InputAnchors => Anchors.Where(a => a.IsInput);
|
||||
public IEnumerable<Anchor> OutputAnchors => Anchors.Where(a => !a.IsInput);
|
||||
public BoxCollider2D Box {
|
||||
get
|
||||
{
|
||||
if (_box == null)
|
||||
_box = GetComponentInChildren<BoxCollider2D>();
|
||||
return _box;
|
||||
}
|
||||
}
|
||||
public GateSprite Sprite
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_sprite == null)
|
||||
_sprite = GetComponentInChildren<GateSprite>();
|
||||
return _sprite;
|
||||
}
|
||||
}
|
||||
public GateDefinition Definition
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_definition == null)
|
||||
_definition = GateDefinition.Get(GateType, this);
|
||||
return _definition;
|
||||
}
|
||||
}
|
||||
public IEnumerable<Anchor> Anchors
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_anchors == null)
|
||||
_anchors = GetComponentsInChildren<Anchor>().ToList();
|
||||
return _anchors;
|
||||
}
|
||||
}
|
||||
public IEnumerable<Anchor> InputAnchors => Anchors.Where(a => a.IsInput);
|
||||
public IEnumerable<Anchor> OutputAnchors => Anchors.Where(a => !a.IsInput);
|
||||
public BoxCollider2D Box {
|
||||
get
|
||||
{
|
||||
if (_box == null)
|
||||
_box = GetComponentInChildren<BoxCollider2D>();
|
||||
return _box;
|
||||
}
|
||||
}
|
||||
public GateSprite Sprite
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_sprite == null)
|
||||
_sprite = GetComponentInChildren<GateSprite>();
|
||||
return _sprite;
|
||||
}
|
||||
}
|
||||
public GateDefinition Definition
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_definition == null)
|
||||
_definition = GateDefinition.Get(GateType, this);
|
||||
return _definition;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private IEnumerable<Anchor> _anchors;
|
||||
private GateDefinition _definition;
|
||||
private int _lastState = -1;
|
||||
private BoxCollider2D _box;
|
||||
private GateSprite _sprite;
|
||||
private IEnumerable<Anchor> _anchors;
|
||||
private GateDefinition _definition;
|
||||
private int _lastState = -1;
|
||||
private BoxCollider2D _box;
|
||||
private GateSprite _sprite;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Utils.RandomName(Definition.Name, gameObject);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
Utils.RandomName(Definition.Name, gameObject);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
UpdateState();
|
||||
}
|
||||
// Update is called once per frame
|
||||
private void Update()
|
||||
{
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
public bool HasInputAnchor(Anchor target)
|
||||
{
|
||||
return !Definition.HasState && (
|
||||
InputAnchors.Contains(target) ||
|
||||
InputAnchors.Any(a => a.HasInputAnchor(target))
|
||||
);
|
||||
}
|
||||
public bool HasInputAnchor(Anchor target)
|
||||
{
|
||||
return !Definition.HasState && (
|
||||
InputAnchors.Contains(target) ||
|
||||
InputAnchors.Any(a => a.HasInputAnchor(target))
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
private void UpdateState()
|
||||
{
|
||||
var state = Definition.GetState(this).ToInt();
|
||||
if (state != _lastState)
|
||||
{
|
||||
Definition.Compute(this);
|
||||
_lastState = state;
|
||||
}
|
||||
}
|
||||
private void UpdateState()
|
||||
{
|
||||
var state = Definition.GetState(this).ToInt();
|
||||
if (state != _lastState)
|
||||
{
|
||||
Definition.Compute(this);
|
||||
_lastState = state;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,53 +6,53 @@ using UntitledLogicGame.Workspace.Gates;
|
||||
|
||||
namespace UntitledLogicGame.Workspace
|
||||
{
|
||||
public class GateSprite : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
public class GateSprite : MonoBehaviour
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
#region Public Properties
|
||||
|
||||
public bool Hovering { get; internal set; }
|
||||
public bool Hovering { get; internal set; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private Gate _gate;
|
||||
private Gate _gate;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_gate = GetComponentInParent<Gate>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
_gate = GetComponentInParent<Gate>();
|
||||
}
|
||||
|
||||
private void OnMouseEnter()
|
||||
{
|
||||
GameManager.Instance.CurrentGate = _gate;
|
||||
Hovering = true;
|
||||
}
|
||||
private void OnMouseEnter()
|
||||
{
|
||||
GameManager.Instance.CurrentGate = _gate;
|
||||
Hovering = true;
|
||||
}
|
||||
|
||||
private void OnMouseExit()
|
||||
{
|
||||
if (_gate.Equals(GameManager.Instance.CurrentGate))
|
||||
GameManager.Instance.CurrentGate = null;
|
||||
Hovering = false;
|
||||
}
|
||||
private void OnMouseExit()
|
||||
{
|
||||
if (_gate.Equals(GameManager.Instance.CurrentGate))
|
||||
GameManager.Instance.CurrentGate = null;
|
||||
Hovering = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,35 @@
|
||||
namespace UntitledLogicGame.Workspace.Gates
|
||||
{
|
||||
public enum GateType
|
||||
{
|
||||
// 000 - Technical
|
||||
None = 000,
|
||||
// 100 - I/O
|
||||
IN = 100,
|
||||
OUT = 110,
|
||||
// 200 - Basic
|
||||
BUF = 200,
|
||||
AND = 210,
|
||||
OR = 220,
|
||||
XOR = 230,
|
||||
public enum GateType
|
||||
{
|
||||
// 000 - Technical
|
||||
None = 000,
|
||||
// 100 - I/O
|
||||
IN = 100,
|
||||
OUT = 110,
|
||||
// 200 - Basic
|
||||
BUF = 200,
|
||||
AND = 210,
|
||||
OR = 220,
|
||||
XOR = 230,
|
||||
NOT = 240,
|
||||
NAND = 250,
|
||||
NOR = 260,
|
||||
XNOR = 270,
|
||||
// 300 - Latches
|
||||
SRLatch = 300,
|
||||
JKLatch = 310,
|
||||
DLatch = 320,
|
||||
// 500 - Flip-Flops
|
||||
SRFlipFlop = 400,
|
||||
JKFlipFlop = 410,
|
||||
DFlipFlop = 420,
|
||||
TFlipFlop = 430,
|
||||
// 500 - Arithmetic
|
||||
HalfAdd = 500,
|
||||
FullAdd = 510,
|
||||
HalfSub = 520,
|
||||
FullSub = 530,
|
||||
JKLatch = 310,
|
||||
DLatch = 320,
|
||||
// 500 - Flip-Flops
|
||||
SRFlipFlop = 400,
|
||||
JKFlipFlop = 410,
|
||||
DFlipFlop = 420,
|
||||
TFlipFlop = 430,
|
||||
// 500 - Arithmetic
|
||||
HalfAdd = 500,
|
||||
FullAdd = 510,
|
||||
HalfSub = 520,
|
||||
FullSub = 530,
|
||||
// 600 - Data
|
||||
Mux = 610,
|
||||
Demux = 620,
|
||||
|
||||
@@ -3,77 +3,77 @@ using System.Linq;
|
||||
|
||||
namespace UntitledLogicGame.Workspace.Gates
|
||||
{
|
||||
public class InputState : State
|
||||
{
|
||||
public InputState(IEnumerable<bool> args) : base(args) { }
|
||||
public class InputState : State
|
||||
{
|
||||
public InputState(IEnumerable<bool> args) : base(args) { }
|
||||
|
||||
public InputState(params bool[] args) : base(args) { }
|
||||
public InputState(params bool[] args) : base(args) { }
|
||||
|
||||
public InputState(int len) : base(len) { }
|
||||
}
|
||||
public InputState(int len) : base(len) { }
|
||||
}
|
||||
|
||||
public class OutputState : State
|
||||
{
|
||||
public OutputState(IEnumerable<bool> args) : base(args) { }
|
||||
{
|
||||
public OutputState(IEnumerable<bool> args) : base(args) { }
|
||||
|
||||
public OutputState(params bool[] args) : base(args) { }
|
||||
public OutputState(params bool[] args) : base(args) { }
|
||||
|
||||
public OutputState(int len) : base(len) { }
|
||||
}
|
||||
public OutputState(int len) : base(len) { }
|
||||
}
|
||||
|
||||
public abstract class State
|
||||
{
|
||||
internal int Length => values.Length;
|
||||
{
|
||||
internal int Length => values.Length;
|
||||
|
||||
internal bool[] values;
|
||||
internal bool[] values;
|
||||
|
||||
public State(IEnumerable<bool> args)
|
||||
{
|
||||
values = args.ToArray();
|
||||
}
|
||||
public State(IEnumerable<bool> args)
|
||||
{
|
||||
values = args.ToArray();
|
||||
}
|
||||
|
||||
public State(params bool[] args)
|
||||
{
|
||||
values = args;
|
||||
}
|
||||
public State(params bool[] args)
|
||||
{
|
||||
values = args;
|
||||
}
|
||||
|
||||
public State(int len)
|
||||
{
|
||||
values = new bool[len];
|
||||
}
|
||||
public State(int len)
|
||||
{
|
||||
values = new bool[len];
|
||||
}
|
||||
|
||||
public bool this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= values.Length)
|
||||
return false;
|
||||
return values[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index >= 0 && index < values.Length)
|
||||
values[index] = value;
|
||||
}
|
||||
}
|
||||
public bool this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index < 0 || index >= values.Length)
|
||||
return false;
|
||||
return values[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (index >= 0 && index < values.Length)
|
||||
values[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is State state && Enumerable.SequenceEqual(values, state.values);
|
||||
}
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return obj is State state && Enumerable.SequenceEqual(values, state.values);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
//https://stackoverflow.com/questions/6832139/gethashcode-from-booleans-only
|
||||
int hash = 17;
|
||||
for (int index = 0; index < values.Length; index++)
|
||||
hash = hash * 23 + values[index].GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
//https://stackoverflow.com/questions/6832139/gethashcode-from-booleans-only
|
||||
int hash = 17;
|
||||
for (int index = 0; index < values.Length; index++)
|
||||
hash = hash * 23 + values[index].GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(",", values);
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Join(",", values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,62 +5,62 @@ using UnityEngine;
|
||||
|
||||
namespace UntitledLogicGame.Workspace
|
||||
{
|
||||
public class InputGate : Gate
|
||||
{
|
||||
#region Unity Properties
|
||||
public class InputGate : Gate
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
#region Public Properties
|
||||
|
||||
public bool State { get; set; }
|
||||
public bool State { get; set; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private Anchor OutputAnchor {
|
||||
get
|
||||
{
|
||||
if (_outputAnchor == null)
|
||||
_outputAnchor = Anchors.First(g => g.Name == "Q");
|
||||
return _outputAnchor;
|
||||
}
|
||||
}
|
||||
private Anchor _outputAnchor;
|
||||
private Anchor OutputAnchor {
|
||||
get
|
||||
{
|
||||
if (_outputAnchor == null)
|
||||
_outputAnchor = Anchors.First(g => g.Name == "Q");
|
||||
return _outputAnchor;
|
||||
}
|
||||
}
|
||||
private Anchor _outputAnchor;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Utils.RandomName("Input", gameObject);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
Utils.RandomName("Input", gameObject);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateState();
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
private void UpdateState()
|
||||
{
|
||||
if ((Sprite.Hovering || OutputAnchor.Hovering) && PointerManager.Instance.DoubleClick())
|
||||
{
|
||||
State = !State;
|
||||
OutputAnchor.Activated = State;
|
||||
}
|
||||
}
|
||||
private void UpdateState()
|
||||
{
|
||||
if ((Sprite.Hovering || OutputAnchor.Hovering) && PointerManager.Instance.DoubleClick())
|
||||
{
|
||||
State = !State;
|
||||
OutputAnchor.Activated = State;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,53 +5,53 @@ using UnityEngine;
|
||||
|
||||
namespace UntitledLogicGame.Workspace
|
||||
{
|
||||
public class OutputGate : Gate
|
||||
{
|
||||
#region Unity Properties
|
||||
public class OutputGate : Gate
|
||||
{
|
||||
#region Unity Properties
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
#region Public Properties
|
||||
|
||||
public bool State {
|
||||
get
|
||||
{
|
||||
return InputAnchor.Activated;
|
||||
}
|
||||
}
|
||||
public bool State {
|
||||
get
|
||||
{
|
||||
return InputAnchor.Activated;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
#region Private Properties
|
||||
|
||||
private Anchor InputAnchor {
|
||||
get
|
||||
{
|
||||
if (_inputAnchor == null)
|
||||
_inputAnchor = Anchors.First(g => g.Name == "A");
|
||||
return _inputAnchor;
|
||||
}
|
||||
}
|
||||
private Anchor _inputAnchor;
|
||||
private Anchor InputAnchor {
|
||||
get
|
||||
{
|
||||
if (_inputAnchor == null)
|
||||
_inputAnchor = Anchors.First(g => g.Name == "A");
|
||||
return _inputAnchor;
|
||||
}
|
||||
}
|
||||
private Anchor _inputAnchor;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Unity Methods
|
||||
#region Unity Methods
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Utils.RandomName("Output", gameObject);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
Utils.RandomName("Output", gameObject);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
#region Public Methods
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
#region Private Methods
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ Properties {
|
||||
SubShader {
|
||||
|
||||
Tags
|
||||
{
|
||||
{
|
||||
"Queue"="Overlay"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
|
||||
@@ -1,308 +1,308 @@
|
||||
Shader "TextMeshPro/Distance Field SSD" {
|
||||
|
||||
Properties {
|
||||
_FaceTex ("Face Texture", 2D) = "white" {}
|
||||
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
|
||||
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
_FaceTex ("Face Texture", 2D) = "white" {}
|
||||
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
|
||||
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineTex ("Outline Texture", 2D) = "white" {}
|
||||
_OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
|
||||
_OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
|
||||
_OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_OutlineTex ("Outline Texture", 2D) = "white" {}
|
||||
_OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
|
||||
_OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
|
||||
_OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
|
||||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||
|
||||
_Bevel ("Bevel", Range(0,1)) = 0.5
|
||||
_BevelOffset ("Bevel Offset", Range(-0.5,0.5)) = 0
|
||||
_BevelWidth ("Bevel Width", Range(-.5,0.5)) = 0
|
||||
_BevelClamp ("Bevel Clamp", Range(0,1)) = 0
|
||||
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
|
||||
_Bevel ("Bevel", Range(0,1)) = 0.5
|
||||
_BevelOffset ("Bevel Offset", Range(-0.5,0.5)) = 0
|
||||
_BevelWidth ("Bevel Width", Range(-.5,0.5)) = 0
|
||||
_BevelClamp ("Bevel Clamp", Range(0,1)) = 0
|
||||
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
|
||||
|
||||
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
|
||||
[HDR]_SpecularColor ("Specular", Color) = (1,1,1,1)
|
||||
_SpecularPower ("Specular", Range(0,4)) = 2.0
|
||||
_Reflectivity ("Reflectivity", Range(5.0,15.0)) = 10
|
||||
_Diffuse ("Diffuse", Range(0,1)) = 0.5
|
||||
_Ambient ("Ambient", Range(1,0)) = 0.5
|
||||
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
|
||||
[HDR]_SpecularColor ("Specular", Color) = (1,1,1,1)
|
||||
_SpecularPower ("Specular", Range(0,4)) = 2.0
|
||||
_Reflectivity ("Reflectivity", Range(5.0,15.0)) = 10
|
||||
_Diffuse ("Diffuse", Range(0,1)) = 0.5
|
||||
_Ambient ("Ambient", Range(1,0)) = 0.5
|
||||
|
||||
_BumpMap ("Normal map", 2D) = "bump" {}
|
||||
_BumpOutline ("Bump Outline", Range(0,1)) = 0
|
||||
_BumpFace ("Bump Face", Range(0,1)) = 0
|
||||
_BumpMap ("Normal map", 2D) = "bump" {}
|
||||
_BumpOutline ("Bump Outline", Range(0,1)) = 0
|
||||
_BumpFace ("Bump Face", Range(0,1)) = 0
|
||||
|
||||
_ReflectFaceColor ("Reflection Color", Color) = (0,0,0,1)
|
||||
_ReflectOutlineColor("Reflection Color", Color) = (0,0,0,1)
|
||||
_Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
|
||||
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
|
||||
_ReflectFaceColor ("Reflection Color", Color) = (0,0,0,1)
|
||||
_ReflectOutlineColor("Reflection Color", Color) = (0,0,0,1)
|
||||
_Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
|
||||
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
|
||||
|
||||
|
||||
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
|
||||
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||
|
||||
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_GlowOffset ("Offset", Range(-1,1)) = 0
|
||||
_GlowInner ("Inner", Range(0,1)) = 0.05
|
||||
_GlowOuter ("Outer", Range(0,1)) = 0.05
|
||||
_GlowPower ("Falloff", Range(1, 0)) = 0.75
|
||||
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5)
|
||||
_GlowOffset ("Offset", Range(-1,1)) = 0
|
||||
_GlowInner ("Inner", Range(0,1)) = 0.05
|
||||
_GlowOuter ("Outer", Range(0,1)) = 0.05
|
||||
_GlowPower ("Falloff", Range(1, 0)) = 0.75
|
||||
|
||||
_WeightNormal ("Weight Normal", float) = 0
|
||||
_WeightBold ("Weight Bold", float) = 0.5
|
||||
_WeightNormal ("Weight Normal", float) = 0
|
||||
_WeightBold ("Weight Bold", float) = 0.5
|
||||
|
||||
_ShaderFlags ("Flags", float) = 0
|
||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||
_ShaderFlags ("Flags", float) = 0
|
||||
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth ("Texture Width", float) = 512
|
||||
_TextureHeight ("Texture Height", float) = 512
|
||||
_GradientScale ("Gradient Scale", float) = 5.0
|
||||
_ScaleX ("Scale X", float) = 1.0
|
||||
_ScaleY ("Scale Y", float) = 1.0
|
||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||
_Sharpness ("Sharpness", Range(-1,1)) = 0
|
||||
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||
_TextureWidth ("Texture Width", float) = 512
|
||||
_TextureHeight ("Texture Height", float) = 512
|
||||
_GradientScale ("Gradient Scale", float) = 5.0
|
||||
_ScaleX ("Scale X", float) = 1.0
|
||||
_ScaleY ("Scale Y", float) = 1.0
|
||||
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||
_Sharpness ("Sharpness", Range(-1,1)) = 0
|
||||
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||
|
||||
_MaskCoord ("Mask Coordinates", vector) = (0, 0, 32767, 32767)
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
_MaskCoord ("Mask Coordinates", vector) = (0, 0, 32767, 32767)
|
||||
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||
|
||||
_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
|
||||
_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
|
||||
|
||||
_CullMode ("Cull Mode", Float) = 0
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
_CullMode ("Cull Mode", Float) = 0
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
"RenderType" = "Transparent"
|
||||
}
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
"RenderType" = "Transparent"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull[_CullMode]
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
Fog { Mode Off }
|
||||
ZTest[unity_GUIZTestMode]
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask[_ColorMask]
|
||||
Cull[_CullMode]
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
Fog { Mode Off }
|
||||
ZTest[unity_GUIZTestMode]
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask[_ColorMask]
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex VertShader
|
||||
#pragma fragment PixShader
|
||||
#pragma shader_feature __ BEVEL_ON
|
||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
||||
#pragma shader_feature __ GLOW_ON
|
||||
#pragma shader_feature __ FORCE_LINEAR
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex VertShader
|
||||
#pragma fragment PixShader
|
||||
#pragma shader_feature __ BEVEL_ON
|
||||
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
||||
#pragma shader_feature __ GLOW_ON
|
||||
#pragma shader_feature __ FORCE_LINEAR
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "TMPro_Properties.cginc"
|
||||
#include "TMPro.cginc"
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
#include "TMPro_Properties.cginc"
|
||||
#include "TMPro.cginc"
|
||||
|
||||
struct vertex_t {
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
struct vertex_t {
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
struct pixel_t {
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 position : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 atlas : TEXCOORD0;
|
||||
float weight : TEXCOORD1;
|
||||
float2 mask : TEXCOORD2; // Position in object space(xy)
|
||||
float3 viewDir : TEXCOORD3;
|
||||
struct pixel_t {
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 position : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 atlas : TEXCOORD0;
|
||||
float weight : TEXCOORD1;
|
||||
float2 mask : TEXCOORD2; // Position in object space(xy)
|
||||
float3 viewDir : TEXCOORD3;
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float2 texcoord2 : TEXCOORD4;
|
||||
float4 underlayColor : COLOR1;
|
||||
#endif
|
||||
float4 textures : TEXCOORD5;
|
||||
};
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float2 texcoord2 : TEXCOORD4;
|
||||
float4 underlayColor : COLOR1;
|
||||
#endif
|
||||
float4 textures : TEXCOORD5;
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
float4 _FaceTex_ST;
|
||||
float4 _OutlineTex_ST;
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
float4 _FaceTex_ST;
|
||||
float4 _OutlineTex_ST;
|
||||
|
||||
float4 SRGBToLinear(float4 rgba) {
|
||||
return float4(lerp(rgba.rgb / 12.92f, pow((rgba.rgb + 0.055f) / 1.055f, 2.4f), step(0.04045f, rgba.rgb)), rgba.a);
|
||||
}
|
||||
float4 SRGBToLinear(float4 rgba) {
|
||||
return float4(lerp(rgba.rgb / 12.92f, pow((rgba.rgb + 0.055f) / 1.055f, 2.4f), step(0.04045f, rgba.rgb)), rgba.a);
|
||||
}
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
pixel_t output;
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
pixel_t output;
|
||||
|
||||
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input,output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input,output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 underlayColor = _UnderlayColor;
|
||||
underlayColor.rgb *= underlayColor.a;
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 underlayColor = _UnderlayColor;
|
||||
underlayColor.rgb *= underlayColor.a;
|
||||
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
||||
float2 bOffset = float2(x, y);
|
||||
#endif
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
||||
float2 bOffset = float2(x, y);
|
||||
#endif
|
||||
|
||||
// Generate UV for the Masking Texture
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
// Generate UV for the Masking Texture
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
|
||||
// Support for texture tiling and offset
|
||||
float2 textureUV = UnpackUV(input.texcoord1.x);
|
||||
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
|
||||
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
|
||||
// Support for texture tiling and offset
|
||||
float2 textureUV = UnpackUV(input.texcoord1.x);
|
||||
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
|
||||
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
|
||||
|
||||
float4 color = input.color;
|
||||
#if (FORCE_LINEAR && !UNITY_COLORSPACE_GAMMA)
|
||||
color = SRGBToLinear(input.color);
|
||||
#endif
|
||||
float4 color = input.color;
|
||||
#if (FORCE_LINEAR && !UNITY_COLORSPACE_GAMMA)
|
||||
color = SRGBToLinear(input.color);
|
||||
#endif
|
||||
|
||||
output.position = vPosition;
|
||||
output.color = color;
|
||||
output.atlas = input.texcoord0;
|
||||
output.weight = weight;
|
||||
output.mask = half2(vert.xy * 2 - clampedRect.xy - clampedRect.zw);
|
||||
output.viewDir = mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz);
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
output.texcoord2 = input.texcoord0 + bOffset;
|
||||
output.underlayColor = underlayColor;
|
||||
#endif
|
||||
output.textures = float4(faceUV, outlineUV);
|
||||
output.position = vPosition;
|
||||
output.color = color;
|
||||
output.atlas = input.texcoord0;
|
||||
output.weight = weight;
|
||||
output.mask = half2(vert.xy * 2 - clampedRect.xy - clampedRect.zw);
|
||||
output.viewDir = mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz);
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
output.texcoord2 = input.texcoord0 + bOffset;
|
||||
output.underlayColor = underlayColor;
|
||||
#endif
|
||||
output.textures = float4(faceUV, outlineUV);
|
||||
|
||||
return output;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
fixed4 PixShader(pixel_t input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
fixed4 PixShader(pixel_t input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
|
||||
float c = tex2D(_MainTex, input.atlas).a;
|
||||
float c = tex2D(_MainTex, input.atlas).a;
|
||||
|
||||
float2 pixelSize = float2(ddx(input.atlas.y), ddy(input.atlas.y));
|
||||
pixelSize *= _TextureWidth * .75;
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize)) * _GradientScale * (_Sharpness + 1);
|
||||
float2 pixelSize = float2(ddx(input.atlas.y), ddy(input.atlas.y));
|
||||
pixelSize *= _TextureWidth * .75;
|
||||
float scale = rsqrt(dot(pixelSize, pixelSize)) * _GradientScale * (_Sharpness + 1);
|
||||
|
||||
float weight = input.weight;
|
||||
float bias = (.5 - weight) + (.5 / scale);
|
||||
float sd = (bias - c) * scale;
|
||||
float weight = input.weight;
|
||||
float bias = (.5 - weight) + (.5 / scale);
|
||||
float sd = (bias - c) * scale;
|
||||
|
||||
float outline = (_OutlineWidth * _ScaleRatioA) * scale;
|
||||
float softness = (_OutlineSoftness * _ScaleRatioA) * scale;
|
||||
float outline = (_OutlineWidth * _ScaleRatioA) * scale;
|
||||
float softness = (_OutlineSoftness * _ScaleRatioA) * scale;
|
||||
|
||||
half4 faceColor = _FaceColor;
|
||||
half4 outlineColor = _OutlineColor;
|
||||
half4 faceColor = _FaceColor;
|
||||
half4 outlineColor = _OutlineColor;
|
||||
|
||||
faceColor.rgb *= input.color.rgb;
|
||||
faceColor.rgb *= input.color.rgb;
|
||||
|
||||
faceColor *= tex2D(_FaceTex, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y);
|
||||
outlineColor *= tex2D(_OutlineTex, input.textures.zw + float2(_OutlineUVSpeedX, _OutlineUVSpeedY) * _Time.y);
|
||||
faceColor *= tex2D(_FaceTex, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y);
|
||||
outlineColor *= tex2D(_OutlineTex, input.textures.zw + float2(_OutlineUVSpeedX, _OutlineUVSpeedY) * _Time.y);
|
||||
|
||||
faceColor = GetColor(sd, faceColor, outlineColor, outline, softness);
|
||||
faceColor = GetColor(sd, faceColor, outlineColor, outline, softness);
|
||||
|
||||
#if BEVEL_ON
|
||||
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
|
||||
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
|
||||
#if BEVEL_ON
|
||||
float3 dxy = float3(0.5 / _TextureWidth, 0.5 / _TextureHeight, 0);
|
||||
float3 n = GetSurfaceNormal(input.atlas, weight, dxy);
|
||||
|
||||
float3 bump = UnpackNormal(tex2D(_BumpMap, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y)).xyz;
|
||||
bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5));
|
||||
n = normalize(n - bump);
|
||||
float3 bump = UnpackNormal(tex2D(_BumpMap, input.textures.xy + float2(_FaceUVSpeedX, _FaceUVSpeedY) * _Time.y)).xyz;
|
||||
bump *= lerp(_BumpFace, _BumpOutline, saturate(sd + outline * 0.5));
|
||||
n = normalize(n - bump);
|
||||
|
||||
float3 light = normalize(float3(sin(_LightAngle), cos(_LightAngle), -1.0));
|
||||
float3 light = normalize(float3(sin(_LightAngle), cos(_LightAngle), -1.0));
|
||||
|
||||
float3 col = GetSpecular(n, light);
|
||||
faceColor.rgb += col * faceColor.a;
|
||||
faceColor.rgb *= 1 - (dot(n, light) * _Diffuse);
|
||||
faceColor.rgb *= lerp(_Ambient, 1, n.z * n.z);
|
||||
float3 col = GetSpecular(n, light);
|
||||
faceColor.rgb += col * faceColor.a;
|
||||
faceColor.rgb *= 1 - (dot(n, light) * _Diffuse);
|
||||
faceColor.rgb *= lerp(_Ambient, 1, n.z * n.z);
|
||||
|
||||
fixed4 reflcol = texCUBE(_Cube, reflect(input.viewDir, -n));
|
||||
faceColor.rgb += reflcol.rgb * lerp(_ReflectFaceColor.rgb, _ReflectOutlineColor.rgb, saturate(sd + outline * 0.5)) * faceColor.a;
|
||||
#endif
|
||||
fixed4 reflcol = texCUBE(_Cube, reflect(input.viewDir, -n));
|
||||
faceColor.rgb += reflcol.rgb * lerp(_ReflectFaceColor.rgb, _ReflectOutlineColor.rgb, saturate(sd + outline * 0.5)) * faceColor.a;
|
||||
#endif
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float bScale = scale;
|
||||
bScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * bScale);
|
||||
float bBias = (0.5 - weight) * bScale - 0.5 - ((_UnderlayDilate * _ScaleRatioC) * 0.5 * bScale);
|
||||
#endif
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float bScale = scale;
|
||||
bScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * bScale);
|
||||
float bBias = (0.5 - weight) * bScale - 0.5 - ((_UnderlayDilate * _ScaleRatioC) * 0.5 * bScale);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_ON
|
||||
float d = tex2D(_MainTex, input.texcoord2.xy).a * bScale;
|
||||
faceColor += input.underlayColor * saturate(d - bBias) * (1 - faceColor.a);
|
||||
#endif
|
||||
#if UNDERLAY_ON
|
||||
float d = tex2D(_MainTex, input.texcoord2.xy).a * bScale;
|
||||
faceColor += input.underlayColor * saturate(d - bBias) * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_INNER
|
||||
float d = tex2D(_MainTex, input.texcoord2.xy).a * bScale;
|
||||
faceColor += input.underlayColor * (1 - saturate(d - bBias)) * saturate(1 - sd) * (1 - faceColor.a);
|
||||
#endif
|
||||
#if UNDERLAY_INNER
|
||||
float d = tex2D(_MainTex, input.texcoord2.xy).a * bScale;
|
||||
faceColor += input.underlayColor * (1 - saturate(d - bBias)) * saturate(1 - sd) * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if GLOW_ON
|
||||
float4 glowColor = GetGlowColor(sd, scale);
|
||||
faceColor.rgb += glowColor.rgb * glowColor.a;
|
||||
#endif
|
||||
#if GLOW_ON
|
||||
float4 glowColor = GetGlowColor(sd, scale);
|
||||
faceColor.rgb += glowColor.rgb * glowColor.a;
|
||||
#endif
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
float2 maskZW = 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + (1 / scale));
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW);
|
||||
faceColor *= m.x * m.y;
|
||||
#endif
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
float2 maskZW = 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + (1 / scale));
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW);
|
||||
faceColor *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(faceColor.a - 0.001);
|
||||
#endif
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(faceColor.a - 0.001);
|
||||
#endif
|
||||
|
||||
return faceColor * input.color.a;
|
||||
}
|
||||
return faceColor * input.color.a;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback "TextMeshPro/Mobile/Distance Field"
|
||||
|
||||
@@ -233,7 +233,7 @@ SubShader {
|
||||
c *= input.texcoord1.z;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(c.a - 0.001);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ Properties {
|
||||
|
||||
SubShader {
|
||||
Tags
|
||||
{
|
||||
{
|
||||
"Queue"="Overlay"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
@@ -226,7 +226,7 @@ SubShader {
|
||||
c *= input.texcoord1.z;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(c.a - 0.001);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ Properties {
|
||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
_CullMode ("Cull Mode", Float) = 0
|
||||
_CullMode ("Cull Mode", Float) = 0
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
Shader "TextMeshPro/Mobile/Distance Field" {
|
||||
|
||||
Properties {
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||
|
||||
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
|
||||
@@ -74,7 +74,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float2 uv_MainTex;
|
||||
float2 uv2_FaceTex;
|
||||
float2 uv2_OutlineTex;
|
||||
float2 uv2_OutlineTex;
|
||||
float2 param; // Weight, Scale
|
||||
float3 viewDirEnv;
|
||||
};
|
||||
|
||||
@@ -24,11 +24,11 @@ Properties {
|
||||
_BumpOutline ("Bump Outline", Range(0,1)) = 0.5
|
||||
_BumpFace ("Bump Face", Range(0,1)) = 0.5
|
||||
|
||||
_ReflectFaceColor ("Face Color", Color) = (0,0,0,1)
|
||||
_ReflectFaceColor ("Face Color", Color) = (0,0,0,1)
|
||||
_ReflectOutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||
_Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
|
||||
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
|
||||
[HDR]_SpecColor ("Specular Color", Color) = (0,0,0,1)
|
||||
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
|
||||
[HDR]_SpecColor ("Specular Color", Color) = (0,0,0,1)
|
||||
|
||||
_FaceShininess ("Face Shininess", Range(0,1)) = 0
|
||||
_OutlineShininess ("Outline Shininess", Range(0,1)) = 0
|
||||
@@ -89,7 +89,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float2 uv_MainTex;
|
||||
float2 uv2_FaceTex;
|
||||
float2 uv2_OutlineTex;
|
||||
float2 uv2_OutlineTex;
|
||||
float2 param; // Weight, Scale
|
||||
float3 viewDirEnv;
|
||||
};
|
||||
|
||||
@@ -305,7 +305,7 @@ SubShader {
|
||||
clip(faceColor.a - 0.001);
|
||||
#endif
|
||||
|
||||
return faceColor * input.color.a;
|
||||
return faceColor * input.color.a;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
@@ -59,16 +59,16 @@ Shader "TextMeshPro/Sprite"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ float3 GetSurfaceNormal(float4 h, float bias)
|
||||
|
||||
float bevelWidth = max(.01, _OutlineWidth+_BevelWidth);
|
||||
|
||||
// Track outline
|
||||
// Track outline
|
||||
h -= .5;
|
||||
h /= bevelWidth;
|
||||
h = saturate(h+.5);
|
||||
@@ -49,7 +49,7 @@ float3 GetSurfaceNormal(float4 h, float bias)
|
||||
float3 GetSurfaceNormal(float2 uv, float bias, float3 delta)
|
||||
{
|
||||
// Read "height field"
|
||||
float4 h = {tex2D(_MainTex, uv - delta.xz).a,
|
||||
float4 h = {tex2D(_MainTex, uv - delta.xz).a,
|
||||
tex2D(_MainTex, uv + delta.xz).a,
|
||||
tex2D(_MainTex, uv - delta.zy).a,
|
||||
tex2D(_MainTex, uv + delta.zy).a};
|
||||
|
||||
@@ -1,157 +1,157 @@
|
||||
struct vertex_t {
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
struct pixel_t {
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 position : SV_POSITION;
|
||||
float4 faceColor : COLOR;
|
||||
float4 outlineColor : COLOR1;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 param : TEXCOORD1; // weight, scaleRatio
|
||||
float2 mask : TEXCOORD2;
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 texcoord2 : TEXCOORD3;
|
||||
float4 underlayColor : COLOR2;
|
||||
#endif
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float4 position : SV_POSITION;
|
||||
float4 faceColor : COLOR;
|
||||
float4 outlineColor : COLOR1;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
float4 param : TEXCOORD1; // weight, scaleRatio
|
||||
float2 mask : TEXCOORD2;
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 texcoord2 : TEXCOORD3;
|
||||
float4 underlayColor : COLOR2;
|
||||
#endif
|
||||
};
|
||||
|
||||
float4 SRGBToLinear(float4 rgba) {
|
||||
return float4(lerp(rgba.rgb / 12.92f, pow((rgba.rgb + 0.055f) / 1.055f, 2.4f), step(0.04045f, rgba.rgb)), rgba.a);
|
||||
return float4(lerp(rgba.rgb / 12.92f, pow((rgba.rgb + 0.055f) / 1.055f, 2.4f), step(0.04045f, rgba.rgb)), rgba.a);
|
||||
}
|
||||
|
||||
pixel_t VertShader(vertex_t input)
|
||||
{
|
||||
pixel_t output;
|
||||
pixel_t output;
|
||||
|
||||
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
float bold = step(input.texcoord1.y, 0);
|
||||
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
float4 vert = input.position;
|
||||
vert.x += _VertexOffsetX;
|
||||
vert.y += _VertexOffsetY;
|
||||
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
float4 vPosition = UnityObjectToClipPos(vert);
|
||||
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
|
||||
weight = (weight + _FaceDilate) * _ScaleRatioA * 0.5;
|
||||
|
||||
// Generate UV for the Masking Texture
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
||||
// Generate UV for the Masking Texture
|
||||
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
||||
|
||||
float4 color = input.color;
|
||||
#if (FORCE_LINEAR && !UNITY_COLORSPACE_GAMMA)
|
||||
color = SRGBToLinear(input.color);
|
||||
#endif
|
||||
float4 color = input.color;
|
||||
#if (FORCE_LINEAR && !UNITY_COLORSPACE_GAMMA)
|
||||
color = SRGBToLinear(input.color);
|
||||
#endif
|
||||
|
||||
float opacity = color.a;
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
opacity = 1.0;
|
||||
#endif
|
||||
float opacity = color.a;
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
opacity = 1.0;
|
||||
#endif
|
||||
|
||||
float4 faceColor = float4(color.rgb, opacity) * _FaceColor;
|
||||
faceColor.rgb *= faceColor.a;
|
||||
float4 faceColor = float4(color.rgb, opacity) * _FaceColor;
|
||||
faceColor.rgb *= faceColor.a;
|
||||
|
||||
float4 outlineColor = _OutlineColor;
|
||||
outlineColor.a *= opacity;
|
||||
outlineColor.rgb *= outlineColor.a;
|
||||
float4 outlineColor = _OutlineColor;
|
||||
outlineColor.a *= opacity;
|
||||
outlineColor.rgb *= outlineColor.a;
|
||||
|
||||
output.position = vPosition;
|
||||
output.faceColor = faceColor;
|
||||
output.outlineColor = outlineColor;
|
||||
output.texcoord0 = float4(input.texcoord0.xy, maskUV.xy);
|
||||
output.param = float4(0.5 - weight, 1.3333 * _GradientScale * (_Sharpness + 1) / _TextureWidth, _OutlineWidth * _ScaleRatioA * 0.5, 0);
|
||||
output.position = vPosition;
|
||||
output.faceColor = faceColor;
|
||||
output.outlineColor = outlineColor;
|
||||
output.texcoord0 = float4(input.texcoord0.xy, maskUV.xy);
|
||||
output.param = float4(0.5 - weight, 1.3333 * _GradientScale * (_Sharpness + 1) / _TextureWidth, _OutlineWidth * _ScaleRatioA * 0.5, 0);
|
||||
|
||||
float2 mask = float2(0, 0);
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
mask = vert.xy * 2 - clampedRect.xy - clampedRect.zw;
|
||||
#endif
|
||||
output.mask = mask;
|
||||
float2 mask = float2(0, 0);
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
mask = vert.xy * 2 - clampedRect.xy - clampedRect.zw;
|
||||
#endif
|
||||
output.mask = mask;
|
||||
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 underlayColor = _UnderlayColor;
|
||||
underlayColor.rgb *= underlayColor.a;
|
||||
#if (UNDERLAY_ON || UNDERLAY_INNER)
|
||||
float4 underlayColor = _UnderlayColor;
|
||||
underlayColor.rgb *= underlayColor.a;
|
||||
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
||||
float x = -(_UnderlayOffsetX * _ScaleRatioC) * _GradientScale / _TextureWidth;
|
||||
float y = -(_UnderlayOffsetY * _ScaleRatioC) * _GradientScale / _TextureHeight;
|
||||
|
||||
output.texcoord2 = float4(input.texcoord0 + float2(x, y), input.color.a, 0);
|
||||
output.underlayColor = underlayColor;
|
||||
#endif
|
||||
output.texcoord2 = float4(input.texcoord0 + float2(x, y), input.color.a, 0);
|
||||
output.underlayColor = underlayColor;
|
||||
#endif
|
||||
|
||||
return output;
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 PixShader(pixel_t input) : SV_Target
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
|
||||
float d = tex2D(_MainTex, input.texcoord0.xy).a;
|
||||
float d = tex2D(_MainTex, input.texcoord0.xy).a;
|
||||
|
||||
float2 UV = input.texcoord0.xy;
|
||||
float scale = rsqrt(abs(ddx(UV.x) * ddy(UV.y) - ddy(UV.x) * ddx(UV.y))) * input.param.y;
|
||||
float2 UV = input.texcoord0.xy;
|
||||
float scale = rsqrt(abs(ddx(UV.x) * ddy(UV.y) - ddy(UV.x) * ddx(UV.y))) * input.param.y;
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float layerScale = scale;
|
||||
layerScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * layerScale);
|
||||
float layerBias = input.param.x * layerScale - .5 - ((_UnderlayDilate * _ScaleRatioC) * .5 * layerScale);
|
||||
#endif
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
float layerScale = scale;
|
||||
layerScale /= 1 + ((_UnderlaySoftness * _ScaleRatioC) * layerScale);
|
||||
float layerBias = input.param.x * layerScale - .5 - ((_UnderlayDilate * _ScaleRatioC) * .5 * layerScale);
|
||||
#endif
|
||||
|
||||
scale /= 1 + (_OutlineSoftness * _ScaleRatioA * scale);
|
||||
scale /= 1 + (_OutlineSoftness * _ScaleRatioA * scale);
|
||||
|
||||
float4 faceColor = input.faceColor * saturate((d - input.param.x) * scale + 0.5);
|
||||
float4 faceColor = input.faceColor * saturate((d - input.param.x) * scale + 0.5);
|
||||
|
||||
#ifdef OUTLINE_ON
|
||||
float4 outlineColor = lerp(input.faceColor, input.outlineColor, sqrt(min(1.0, input.param.z * scale * 2)));
|
||||
faceColor = lerp(outlineColor, input.faceColor, saturate((d - input.param.x - input.param.z) * scale + 0.5));
|
||||
faceColor *= saturate((d - input.param.x + input.param.z) * scale + 0.5);
|
||||
#endif
|
||||
#ifdef OUTLINE_ON
|
||||
float4 outlineColor = lerp(input.faceColor, input.outlineColor, sqrt(min(1.0, input.param.z * scale * 2)));
|
||||
faceColor = lerp(outlineColor, input.faceColor, saturate((d - input.param.x - input.param.z) * scale + 0.5));
|
||||
faceColor *= saturate((d - input.param.x + input.param.z) * scale + 0.5);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_ON
|
||||
d = tex2D(_MainTex, input.texcoord2.xy).a * layerScale;
|
||||
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * saturate(d - layerBias) * (1 - faceColor.a);
|
||||
#endif
|
||||
#if UNDERLAY_ON
|
||||
d = tex2D(_MainTex, input.texcoord2.xy).a * layerScale;
|
||||
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * saturate(d - layerBias) * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#if UNDERLAY_INNER
|
||||
float bias = input.param.x * scale - 0.5;
|
||||
float sd = saturate(d * scale - bias - input.param.z);
|
||||
d = tex2D(_MainTex, input.texcoord2.xy).a * layerScale;
|
||||
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * (1 - saturate(d - layerBias)) * sd * (1 - faceColor.a);
|
||||
#endif
|
||||
#if UNDERLAY_INNER
|
||||
float bias = input.param.x * scale - 0.5;
|
||||
float sd = saturate(d * scale - bias - input.param.z);
|
||||
d = tex2D(_MainTex, input.texcoord2.xy).a * layerScale;
|
||||
faceColor += float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a) * (1 - saturate(d - layerBias)) * sd * (1 - faceColor.a);
|
||||
#endif
|
||||
|
||||
#ifdef MASKING
|
||||
float a = abs(_MaskInverse - tex2D(_MaskTex, input.texcoord0.zw).a);
|
||||
float t = a + (1 - _MaskWipeControl) * _MaskEdgeSoftness - _MaskWipeControl;
|
||||
a = saturate(t / _MaskEdgeSoftness);
|
||||
faceColor.rgb = lerp(_MaskEdgeColor.rgb * faceColor.a, faceColor.rgb, a);
|
||||
faceColor *= a;
|
||||
#endif
|
||||
#ifdef MASKING
|
||||
float a = abs(_MaskInverse - tex2D(_MaskTex, input.texcoord0.zw).a);
|
||||
float t = a + (1 - _MaskWipeControl) * _MaskEdgeSoftness - _MaskWipeControl;
|
||||
a = saturate(t / _MaskEdgeSoftness);
|
||||
faceColor.rgb = lerp(_MaskEdgeColor.rgb * faceColor.a, faceColor.rgb, a);
|
||||
faceColor *= a;
|
||||
#endif
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
float2 maskZW = 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + (1 / scale));
|
||||
float2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW);
|
||||
faceColor *= m.x * m.y;
|
||||
#endif
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
float2 maskZW = 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + (1 / scale));
|
||||
float2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW);
|
||||
faceColor *= m.x * m.y;
|
||||
#endif
|
||||
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
faceColor *= input.texcoord2.z;
|
||||
#endif
|
||||
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||
faceColor *= input.texcoord2.z;
|
||||
#endif
|
||||
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(faceColor.a - 0.001);
|
||||
#endif
|
||||
#if UNITY_UI_ALPHACLIP
|
||||
clip(faceColor.a - 0.001);
|
||||
#endif
|
||||
|
||||
return faceColor;
|
||||
return faceColor;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ uniform fixed4 _ReflectFaceColor; // RGB intensity
|
||||
uniform fixed4 _ReflectOutlineColor;
|
||||
//uniform float _EnvTiltX; // v[-1, 1]
|
||||
//uniform float _EnvTiltY; // v[-1, 1]
|
||||
uniform float3 _EnvMatrixRotation;
|
||||
uniform float3 _EnvMatrixRotation;
|
||||
uniform float4x4 _EnvMatrix;
|
||||
|
||||
uniform fixed4 _SpecularColor; // RGB intensity
|
||||
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48757dac925275d4f96aeee179368303
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Executable
Executable
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1a9b9bb9f39fef44b3e7b76dea70d42
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user