public void Destroy() { if (_imageGameObject != null) { _xAxisGizmo.AdjustmentGizmoScript.OnDestroy(); _yAxisGizmo.AdjustmentGizmoScript.OnDestroy(); UnityEngine.Object.Destroy(_xAxisGizmo.AdjustmentGizmoScript.gameObject); UnityEngine.Object.Destroy(_yAxisGizmo.AdjustmentGizmoScript.gameObject); TranslateGizmoAxisScript.Destroy(_xAxisGizmo); TranslateGizmoAxisScript.Destroy(_yAxisGizmo); UnityEngine.Object.Destroy(_parentGameObject); _parentGameObject = null; } }
public ReferenceImage(string view, Texture2D image, ViewToolsUI viewToolsUI) { this.view = view; this.viewToolsUI = viewToolsUI; _parentGameObject = new GameObject(); _parentGameObject.transform.parent = designer.CraftScript?.RootPart.Transform; _gizmoGameObject = new GameObject(); _gizmoGameObject.transform.parent = _parentGameObject.transform; _imageGameObject = new GameObject(); _imageGameObject.transform.parent = _parentGameObject.transform; _image = GameObject.CreatePrimitive(PrimitiveType.Plane); _image.transform.parent = _imageGameObject.transform; _renderer = _image.GetComponent <Renderer> (); _renderer.receiveShadows = false; Transform parent = _gizmoGameObject.transform; _xAxisGizmo = TranslateGizmoAxisScript.Create(parent, () => (!_isLocalOrientation) ? Vector3.right : parent.right, new Color(1f, 0f, 0f), 2.5f, true, designer.GizmoCamera, TranslateGizmoAxisScript.GizmoAxisType.Right); _yAxisGizmo = TranslateGizmoAxisScript.Create(parent, () => (!_isLocalOrientation) ? Vector3.forward : parent.forward, new Color(0f, 1f, 0f), 2.5f, true, designer.GizmoCamera, TranslateGizmoAxisScript.GizmoAxisType.Forward); //_RotateGizmo = RotateGizmoAxisScript.Create (new RotateGizmo (), parent, Utilities.UnityTransform.TransformAxis.X, new Color (1f, 0f, 0f, 1f), 2.5f); _xAxisGizmo.AdjustmentGizmoScript.SetVisibility(false); _yAxisGizmo.AdjustmentGizmoScript.SetVisibility(false); //_XAxisGizmo.name = "XAxisGizmo"; //_YAxisGizmo.name = "YAxisGizmo"; Quaternion ParentRot = _parentGameObject.transform.parent.rotation; _parentGameObject.transform.parent.rotation = designer.ActiveCraftConfiguration.Type == ModApi.Craft.CrafConfigurationType.Plane ? Quaternion.Euler(90f, 0f, 0f) : Quaternion.identity; if (this.view == "Front") { _parentGameObject.transform.rotation = Quaternion.Euler(90f, -90f, -90f); } else if (this.view == "Back") { _parentGameObject.transform.rotation = Quaternion.Euler(90f, 270f, 90f); } else if (this.view == "Top") { _parentGameObject.transform.rotation = Quaternion.Euler(0f, -90f, 0f); } else if (this.view == "Bottom") { _parentGameObject.transform.rotation = Quaternion.Euler(180f, 90f, 0f); } else if (this.view == "Left") { _parentGameObject.transform.rotation = Quaternion.Euler(90f, 0f, 90f); } else if (this.view == "Right") { _parentGameObject.transform.rotation = Quaternion.Euler(90f, 0f, -90f); } _parentGameObject.transform.parent.rotation = ParentRot; //_ParentGameObject.transform.position = (Vector3) _Designer.CraftScript?.RootPart.Transform.position; _parentGameObject.transform.localPosition = new Vector3(); UpdateImage(image); }