2using System.Collections;
3using System.Collections.Generic;
4using System.Runtime.Serialization;
6using NaughtyAttributes;
11using System.Globalization;
18 private MeshRenderer meshRenderer;
22 Transform originalParent1, originalParent2;
24 internal bool constrain =
false;
25 internal bool reparent =
false;
46 if (!constrain)
return;
48 if (Input.GetMouseButtonDown(0))
50 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
52 if (Physics.Raycast(ray, out RaycastHit hit))
54 mesh = hit.collider.gameObject.GetComponent<MeshFilter>().mesh;
55 vertices = mesh.vertices;
57 if (originalParent1 ==
null)
59 originalParent1 = hit.collider.gameObject.transform.parent;
60 GO1 = hit.collider.gameObject.GetComponentInParent<
OffsetHolder>(
true).gameObject;
68 MeshCollider meshCollider = hit.collider as MeshCollider;
69 if (meshCollider ==
null || meshCollider.sharedMesh ==
null)
72 cube.transform.position = hit.point;
75 if (
cube.transform.childCount == 0)
cube.transform.forward = hit.normal;
76 else cube.transform.forward = -hit.normal;
77 if (
cube.transform.childCount == 0)
79 hit.collider.gameObject.transform.SetParent(
cube.transform);
88 GO1.transform.SetParent(originalParent1);
90 originalParent1 =
null;
104 public void isConstrain()
108 cube.SetActive(
true);
110 icon.color =
new Color(0f, 38f/255f, 137f/255f);
115 cube.SetActive(
false);
System.Drawing.Image Image