simple cable management
This commit is contained in:
@@ -99,6 +99,7 @@ MonoBehaviour:
|
||||
Name:
|
||||
IsInput: 0
|
||||
ScaleIncrease: 1.5
|
||||
Orientation: {x: 0, y: 0}
|
||||
--- !u!58 &8643366489253547345
|
||||
CircleCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -122,8 +122,8 @@ LineRenderer:
|
||||
m_Mode: 0
|
||||
m_NumColorKeys: 2
|
||||
m_NumAlphaKeys: 2
|
||||
numCornerVertices: 0
|
||||
numCapVertices: 0
|
||||
numCornerVertices: 90
|
||||
numCapVertices: 90
|
||||
alignment: 0
|
||||
textureMode: 0
|
||||
shadowBias: 0.5
|
||||
|
||||
@@ -229,6 +229,10 @@ PrefabInstance:
|
||||
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
|
||||
@@ -295,6 +299,10 @@ PrefabInstance:
|
||||
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
|
||||
@@ -365,6 +373,10 @@ PrefabInstance:
|
||||
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: B
|
||||
|
||||
@@ -490,11 +490,11 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -10.11
|
||||
value: -10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 2.82
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
@@ -557,11 +557,11 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -10.26
|
||||
value: -10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -4.53
|
||||
value: -4
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace UntitledLogicGame
|
||||
public string Name;
|
||||
public bool IsInput;
|
||||
public float ScaleIncrease;
|
||||
public Vector2 Orientation;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -56,6 +57,7 @@ namespace UntitledLogicGame
|
||||
_scale = transform.localScale;
|
||||
_sprite = GetComponent<SpriteRenderer>();
|
||||
Cables = new List<Cable>();
|
||||
Orientation = Orientation.normalized;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
+52
-3
@@ -88,11 +88,60 @@ namespace UntitledLogicGame
|
||||
_lastActivated = Activated;
|
||||
}
|
||||
|
||||
var startPos = StartAnchor == null ? MouseManager.MousePos : StartAnchor.transform.position;
|
||||
var endPos = EndAnchor == null ? MouseManager.MousePos : EndAnchor.transform.position;
|
||||
if(StartAnchor != null)
|
||||
{
|
||||
if (EndAnchor == null)
|
||||
{
|
||||
_line.positionCount = 2;
|
||||
_line.SetPosition(0, StartAnchor.transform.position);
|
||||
_line.SetPosition(1, MouseManager.MousePos);
|
||||
}
|
||||
else
|
||||
{
|
||||
var startPos = StartAnchor.transform.position;
|
||||
var startOr = StartAnchor.Orientation;
|
||||
var endPos = EndAnchor.transform.position;
|
||||
var endOr = StartAnchor.Orientation;
|
||||
|
||||
_line.positionCount = 4;
|
||||
_line.SetPosition(0, startPos);
|
||||
_line.SetPosition(1, endPos);
|
||||
|
||||
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, 0));
|
||||
_line.SetPosition(2, new Vector3(middle, endPos.y, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
_line.SetPosition(1, new Vector3(startPos.x, endPos.y, 0));
|
||||
_line.SetPosition(2, new Vector3(startPos.x, endPos.y, 0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Mathf.Abs(endOr.x) > 0)
|
||||
{
|
||||
var middle = (startPos.y + endPos.y) / 2;
|
||||
_line.SetPosition(1, new Vector3(startPos.x, middle, 0));
|
||||
_line.SetPosition(2, new Vector3(endPos.x, middle, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
_line.SetPosition(1, new Vector3(endPos.x, startPos.y, 0));
|
||||
_line.SetPosition(2, new Vector3(endPos.x, startPos.y, 0));
|
||||
}
|
||||
}
|
||||
|
||||
_line.SetPosition(3, endPos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_line.positionCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
|
||||
Reference in New Issue
Block a user