/// <summary> /// Create a new text zone. Its a comment zone shown in both views. /// </summary> private void CreateTextZone() { if (m_isCreating) { if (!m_isDragging) { if (InputFunctions.IsClickingOutsideUI()) { m_startPoint = InputFunctions.GetWorldPoint2D(GlobalManager.Instance.GetActiveCamera()); m_endPoint = InputFunctions.GetWorldPoint2D(GlobalManager.Instance.GetActiveCamera()); m_isDragging = true; currentElement = new TextZoneElement { Text = "Commentaire", BackgroundColor = Color.gray, TextColor = Color.black, TextSize = 1 }; currentElement.associated2DObject = Instantiate(textZonePrefab); currentElement.associated3DObject = Instantiate(textZonePrefab); currentElement.associated2DObject.GetComponentInChildren <TextMesh>().fontStyle = FontStyle.Bold; currentElement.associated3DObject.GetComponentInChildren <TextMesh>().fontStyle = FontStyle.Bold; currentElement.associated2DObject.SetLayerRecursively((int)ErgoLayers.Top); currentElement.associated3DObject.SetLayerRecursively((int)ErgoLayers.ThreeD); } } else { m_endPoint = InputFunctions.GetWorldPoint2D(GlobalManager.Instance.GetActiveCamera()); if (InputFunctions.IsClickingOutsideUI()) { m_isCreating = false; m_isDragging = false; m_helpers.Add(currentElement); OperationsBufferScript.Instance.AddAutoSave("Creation zone de texte"); } currentElement.associated2DObject.transform.position = (m_startPoint + m_endPoint) / 2f; currentElement.Position = VectorFunctions.Switch2D3D((m_startPoint + m_endPoint) / 2f); currentElement.associated3DObject.transform.position = currentElement.Position; (currentElement as TextZoneElement).Size = VectorFunctions.Switch2D3D(currentElement .associated2DObject.GetComponent <TextZoneScript>().SetSize(m_startPoint, m_endPoint)); currentElement.associated3DObject.GetComponent <TextZoneScript>().SetSize(m_startPoint, m_endPoint); // CANCEL if (Input.GetMouseButtonDown(1)) { m_isCreating = false; m_isDragging = false; Destroy(currentElement.associated2DObject); currentElement = null; } } } }
/// <summary> /// Destroy gameobject and helper data /// </summary> /// <param name="h">HelperElement data</param> public void DestroyHelpers(HelperElement h) { m_helpers.Remove(h); Destroy(h.associated2DObject); Destroy(h.associated3DObject); }