private void LoadReticles() { var reticlePrefab = Resources.Load("ReticleForEditor") as GameObject; var retAddObj = Instantiate(reticlePrefab, Vector3.zero, Quaternion.identity); reticleCubical = retAddObj.GetComponent <ReticleForEditor>(); reticleCubical.Initialize(); reticleCubical.EnableRenderer(false); reticlePrefab = Resources.Load("SphericalReticleForEditor") as GameObject; retAddObj = Instantiate(reticlePrefab, Vector3.zero, Quaternion.identity); reticleSpherical = retAddObj.GetComponent <SphericalReticleForEditor>(); reticleSpherical.Initialize(); reticleSpherical.EnableRenderer(false); reticlePrefab = Resources.Load("ReticleLinesForEditor") as GameObject; retAddObj = Instantiate(reticlePrefab, Vector3.zero, Quaternion.identity); reticleLinesForEditor = retAddObj.GetComponent <ReticleLinesForEditor>(); reticleLinesForEditor.Initialize(); reticleLinesForEditor.EnableRenderer(false); reticlePrefab = Resources.Load("CapsuleReticleForEditor") as GameObject; retAddObj = Instantiate(reticlePrefab, Vector3.zero, Quaternion.identity); capsuleReticleForEditor = retAddObj.GetComponent <CapsuleReticleForEditor>(); capsuleReticleForEditor.Initialize(); capsuleReticleForEditor.EnableRenderer(false); reticlePrefab = Resources.Load("CylinderReticleForEditor") as GameObject; retAddObj = Instantiate(reticlePrefab, Vector3.zero, Quaternion.identity); cylinderReticleForEditor = retAddObj.GetComponent <CylinderReticleForEditor>(); cylinderReticleForEditor.Initialize(); cylinderReticleForEditor.EnableRenderer(false); }
public void DestroyReticle() { if (Reticle != null) { Object.DestroyImmediate(Reticle.gameObject); Reticle = null; } }
public void OnScene(TerrainToolEditor editor, SceneView sceneview) { if (Reticle == null) { Reticle = editor.LoadReticle <CapsuleReticleForEditor>("CapsuleReticleForEditor"); } if (Event.current.control || Event.current.type == EventType.MouseDown && Event.current.button == 1) { startPosition = null; } var hit = editor.GetIntersectionWithTerrain(true); if (hit.HasValue) { var p = hit.Value.point; if (startPosition.HasValue) { Reticle.SetPositionsAndRadius(startPosition.Value, hit.Value.point, Radius); } else { Reticle.SetPositionsAndRadius(hit.Value.point, hit.Value.point + Vector3.right, Radius); } if (editor.Clicking) { Event.current.Use(); if (!startPosition.HasValue) { startPosition = p; } else { editor.PerformOperation(CreateOperationFromEditor(startPosition.Value, p, editor), sceneview); startPosition = null; } } } }