Beispiel #1
0
    void Update()
    {
        // Add ourselves to the targeted areas when the laser looks at us.
        laserIsLookingHolder.Value = LaserIsLooking;
        if (laserIsLookingHolder.ValueChanged)
        {
            if (laserIsLookingHolder.Value)
            {
                targetedAreas.Add(this);
            }
            else
            {
                targetedAreas.Remove(this);
            }
        }

        // Turn on the laser if it is looking at areas.
        if (targetedAreas.Count > 0)
        {
            laser.TurnOn();
        }
        else
        {
            laser.TurnOff();
        }
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        GUILayout.Space(5);

        VRLaserPointer script = (VRLaserPointer)target;

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Turn on"))
        {
            script.TurnOn();
        }
        if (GUILayout.Button("Turn off"))
        {
            script.TurnOff();
        }
        GUILayout.EndHorizontal();
    }