51 lines
No EOL
1.5 KiB
C#
51 lines
No EOL
1.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using NUnit.Framework.Internal;
|
|
using TMPro;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
[System.Serializable]
|
|
public class RollerProperties : MonoBehaviour {
|
|
[SerializeField] public bool start = false;
|
|
|
|
[SerializeField] public bool clockwise = false;
|
|
|
|
[SerializeField] public GameObject linkTo = null;
|
|
|
|
[SerializeField] public RotationType movement = RotationType.Fixed;
|
|
|
|
protected internal float currentDistance;
|
|
|
|
protected internal GameObject text;
|
|
|
|
private void Update() {
|
|
if (text != null) {
|
|
text.transform.position = transform.position;
|
|
text.transform.rotation = transform.rotation;
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void OnDrawGizmos() {
|
|
foreach (var distanceJoint in gameObject.GetComponents<DistanceJoint2D>()) {
|
|
Gizmos.color = new Color(1, .3f, 0);
|
|
var cableStart = transform.TransformPoint(distanceJoint.anchor);
|
|
var cableEnd = distanceJoint.connectedBody.transform.TransformPoint(distanceJoint.connectedAnchor);
|
|
Gizmos.DrawLine(cableStart, cableEnd);
|
|
Gizmos.color = Color.yellow;
|
|
Gizmos.DrawCube(cableStart, new Vector3(0.1f, 0.1f, 0.1f));
|
|
Gizmos.color = Color.red;
|
|
Gizmos.DrawCube(cableEnd, new Vector3(0.1f, 0.1f, 0.1f));
|
|
}
|
|
}
|
|
|
|
public enum RotationType {
|
|
Fixed,
|
|
Rotatable,
|
|
Powered,
|
|
Free
|
|
}
|
|
} |