Пример #1
0
        static void Callback(object obj)
        {
            if (!(obj is MenuActionClass callBackInformation))
            {
                return;
            }
            MenuActionClass menu = (MenuActionClass)obj;
            Ray             ray  = menu.sceneView.camera.ScreenPointToRay(GetPositionAtMouseLocation(menu.sceneView,
                                                                                                     menu.mousePosition));
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                CreateRootObj();
                GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
                Vector3    position1;
                position1 = hit.point;
                position1 = new Vector3(position1.x, 1f, position1.z);

                go.transform.position = position1;
                Collider collider = go.GetComponent <Collider>();
                //MeshRenderer meshRenderer = go.GetComponent<MeshRenderer>();
                go.AddComponent <GenericScaryEvent>();

                collider.isTrigger         = true;
                Tools.current              = Tool.Move;
                Selection.activeGameObject = go;
                go.transform.parent        = allScaryEventsGameObj.transform;
            }

            menu.currentEvent.Use();
        }
Пример #2
0
        private static void OnSceneGUI(SceneView scView)
        {
            Event currentEvent = Event.current;
            bool  isKeyDown    = currentEvent.type == EventType.KeyDown && currentEvent.keyCode == KeyCode.F1;

            if (isKeyDown)
            {
                GenericMenu     menu = new GenericMenu();
                MenuActionClass info = new MenuActionClass
                {
                    mousePosition = currentEvent.mousePosition,
                    action        = MenuActionClass.CallbackAction.CreateTriggerBox,
                    sceneView     = scView,
                    currentEvent  = currentEvent
                };

                menu.AddItem(new GUIContent("Generic area trigger"), false, Callback, info);
                menu.ShowAsContext();
            }
        }