Ejemplo n.º 1
0
    void OnSceneGUI()
    {
        if (creating || editing)
        {
            var        contorlId = GUIUtility.GetControlID(FocusType.Passive);
            Ray        worldRay;
            RaycastHit hit;
            if (Event.current.button == 0)
            {
                switch (Event.current.GetTypeForControl(contorlId))
                {
                case EventType.MouseDown:

                    worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
                    if (Physics.Raycast(worldRay, out hit))
                    {
                        var station = creator.GetClosestStationTo(hit);
                        //Debug.Log(creator.GetStationName(station));
                        creator.AddStationToNewLine(station);
                    }
                    Event.current.Use();
                    GUIUtility.hotControl = contorlId;
                    break;

                case EventType.MouseUp:
                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                    break;
                }
            }
        }
    }