Пример #1
0
    public void OnSceneGUI()
    {
        CreateLevel creator = (CreateLevel)target;

        if (creator.Editing)
        {
            Event e = Event.current;
            if (e.type == EventType.MouseDown && (!e.control && !e.alt))
            {
                if (e.button == 0)
                {
                    RaycastHit hit;
                    if (Physics.Raycast(HandleUtility.GUIPointToWorldRay(e.mousePosition), out hit))
                    {
                        if (hit.transform.GetComponent <CreateLevel>() != null)
                        {
                            creator.Addcell(creator.transform.InverseTransformPoint(hit.point));
                            EditorUtility.SetDirty(creator.gameObject);
                        }
                    }
                }
                else if (e.button == 1)
                {
                    RaycastHit hit;
                    if (Physics.Raycast(HandleUtility.GUIPointToWorldRay(e.mousePosition), out hit))
                    {
                        if (hit.transform.GetComponent <CreateLevel>() != null)
                        {
                            creator.Removecell(creator.transform.InverseTransformPoint(hit.point));
                            EditorUtility.SetDirty(creator.gameObject);
                        }
                    }
                }
            }
            HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
        }
    }