示例#1
0
    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);
    }
示例#2
0
 public void DestroyReticle()
 {
     if (Reticle != null)
     {
         Object.DestroyImmediate(Reticle.gameObject);
         Reticle = null;
     }
 }
示例#3
0
    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;
                }
            }
        }
    }