Beispiel #1
0
    protected override void Start()
    {
        base.Start();
        meshColl    = GetComponent <MeshCollider>();
        imageCanvas = noteSelectionImage.canvas;
        canvasRect  = imageCanvas.GetComponent <RectTransform>();

        frustumMesh = GetComponent <FrustumMesh>();
        frustumMesh.GetMeshRenderer().enabled = false;
        frustumMesh.GenerateMesh();
        meshColl.sharedMesh = frustumMesh.GetMesh();
        meshColl.convex     = true;
        meshColl.isTrigger  = true;

        noteSelectionImage.gameObject.SetActive(false);
    }
    public override void OnInspectorGUI()
    {
        FrustumMesh mesh = (FrustumMesh)target;

        EditorGUI.BeginChangeCheck();
        float distance  = EditorGUILayout.FloatField("Distance", mesh.distance);
        float halfAngle = EditorGUILayout.FloatField("Half Angle", mesh.halfAngle);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(mesh, "Parameter change");
            mesh.distance  = distance;
            mesh.halfAngle = halfAngle;
            mesh.GenerateMesh();
        }
    }