simple cable management

This commit is contained in:
klemek
2020-12-11 15:56:10 +01:00
parent 4be88ada03
commit 4bc26a2439
6 changed files with 76 additions and 12 deletions
+1
View File
@@ -99,6 +99,7 @@ MonoBehaviour:
Name: Name:
IsInput: 0 IsInput: 0
ScaleIncrease: 1.5 ScaleIncrease: 1.5
Orientation: {x: 0, y: 0}
--- !u!58 &8643366489253547345 --- !u!58 &8643366489253547345
CircleCollider2D: CircleCollider2D:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
+2 -2
View File
@@ -122,8 +122,8 @@ LineRenderer:
m_Mode: 0 m_Mode: 0
m_NumColorKeys: 2 m_NumColorKeys: 2
m_NumAlphaKeys: 2 m_NumAlphaKeys: 2
numCornerVertices: 0 numCornerVertices: 90
numCapVertices: 0 numCapVertices: 90
alignment: 0 alignment: 0
textureMode: 0 textureMode: 0
shadowBias: 0.5 shadowBias: 0.5
+12
View File
@@ -229,6 +229,10 @@ PrefabInstance:
propertyPath: IsInput propertyPath: IsInput
value: 1 value: 1
objectReference: {fileID: 0} 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} - target: {fileID: 1824742176375353076, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: A value: A
@@ -295,6 +299,10 @@ PrefabInstance:
propertyPath: Name propertyPath: Name
value: Q value: Q
objectReference: {fileID: 0} 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} - target: {fileID: 1824742176375353076, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: Q value: Q
@@ -365,6 +373,10 @@ PrefabInstance:
propertyPath: IsInput propertyPath: IsInput
value: 1 value: 1
objectReference: {fileID: 0} 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} - target: {fileID: 1824742176375353076, guid: d2ad1e1266d8af64ca87541a40be7e9f, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: B value: B
+4 -4
View File
@@ -490,11 +490,11 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: -10.11 value: -10
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 2.82 value: 3
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
@@ -557,11 +557,11 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: -10.26 value: -10
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: -4.53 value: -4
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3} - target: {fileID: 2070848596161447923, guid: e13798a14679ee74fa71d11caea77e78, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
+2
View File
@@ -12,6 +12,7 @@ namespace UntitledLogicGame
public string Name; public string Name;
public bool IsInput; public bool IsInput;
public float ScaleIncrease; public float ScaleIncrease;
public Vector2 Orientation;
#endregion #endregion
@@ -56,6 +57,7 @@ namespace UntitledLogicGame
_scale = transform.localScale; _scale = transform.localScale;
_sprite = GetComponent<SpriteRenderer>(); _sprite = GetComponent<SpriteRenderer>();
Cables = new List<Cable>(); Cables = new List<Cable>();
Orientation = Orientation.normalized;
} }
// Update is called once per frame // Update is called once per frame
+54 -5
View File
@@ -88,11 +88,60 @@ namespace UntitledLogicGame
_lastActivated = Activated; _lastActivated = Activated;
} }
var startPos = StartAnchor == null ? MouseManager.MousePos : StartAnchor.transform.position; if(StartAnchor != null)
var endPos = EndAnchor == null ? MouseManager.MousePos : EndAnchor.transform.position; {
_line.positionCount = 2; if (EndAnchor == null)
_line.SetPosition(0, startPos); {
_line.SetPosition(1, endPos); _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);
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() private void OnDestroy()