CubeHelper.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEditor;
  4. using UnityEngine;
  5. public class CubeHelper : MonoBehaviour
  6. {
  7. //public GameObject CubePrefab;
  8. //private const string CubeName = "Highlight";
  9. //[MenuItem("Highlight/Add Highlight")]
  10. //public static void RecalculateColliders()
  11. //{
  12. // var joints = FindObjectsOfType<HingeJoint>();
  13. // foreach (HingeJoint joint in joints)
  14. // {
  15. // for (var i = 0; i < joint.transform.childCount; i++)
  16. // {
  17. // if (joint.transform.GetChild(i).name == CubeName)
  18. // {
  19. // DestroyImmediate(joint.transform.GetChild(i).gameObject);
  20. // }
  21. // }
  22. // if (joint.gameObject.activeSelf)
  23. // {
  24. // //GameObject go = Instantiate(Resources.Load<GameObject>(CubeName));
  25. // //go.transform.SetParent(joint.transform);
  26. // //go.name = CubeName;
  27. // //go.transform.localScale = Vector3.one * 0.1f;
  28. // //go.transform.localPosition = Vector3.zero;
  29. // //go.transform.localRotation = Quaternion.identity;
  30. // //var h = joint.gameObject.AddComponent<JointsHighlighter>();
  31. // //h.HighCube = go;
  32. // var cJoint = joint.gameObject.AddComponent<ConfigurableJoint>();
  33. // cJoint.connectedAnchor = joint.connectedAnchor;
  34. // cJoint.axis = joint.axis;
  35. // cJoint.anchor = joint.anchor;
  36. // cJoint.connectedBody = joint.connectedBody;
  37. // cJoint.massScale = joint.massScale;
  38. // DestroyImmediate(joint);
  39. // }
  40. // }
  41. //}
  42. }