当前位置: 首页>>代码示例>>C#>>正文


C# SceneView.Update方法代码示例

本文整理汇总了C#中SceneView.Update方法的典型用法代码示例。如果您正苦于以下问题:C# SceneView.Update方法的具体用法?C# SceneView.Update怎么用?C# SceneView.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SceneView的用法示例。


在下文中一共展示了SceneView.Update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnUpdate

    void OnUpdate(SceneView sceneView)
    {
        Vector2 screenpos = Event.current.mousePosition;
        screenpos.y = sceneView.camera.pixelHeight - screenpos.y;
        MousePos = sceneView.camera.ScreenPointToRay(screenpos).origin;
        bool withinGrid = MousePos.isWithinGrid();
        if (withinGrid)
        {
            if (Event.current.type == EventType.MouseDown && Event.current.button == 2)
            {
                Active = !Active;
                Event.current.Use(); //keeping this line causes one bug, removing it causes another.
            }
        }
        if (Active)
        {
            UpdateIndicator(withinGrid);
        }
        if(Active && withinGrid)
        {
            if (Event.current.type == EventType.layout)
                HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive));
            Selection.activeObject = null;
            RightClick = isRightPressed(RightClick);
            LeftClick = isLeftPressed(LeftClick);
            Vector2 ScrollVect = getScroll();

            int scroll = Math.Sign(ScrollVect.y);
            if (scroll != 0)
            {
                int nextPiece = (int)selectedIndex + scroll;
                if (nextPiece >= 0 && nextPiece < PieceTypeList.Count)
                {
                    selectedIndex = nextPiece;
                    SetIndicator();
                }
            }
            if (selectedPiece == typeof(Wall))
            {
                Side side;
                Orientation or;
                Vector2 target = Utils.WorldToWallPos(MousePos, out side, out or);
                if (Indicator)
                {
                    Indicator.transform.position = target;
                    Wall wall = Indicator.GetComponent<Wall>();
                    wall.orientation = or;
                }
                if (LeftDown())
                {
                    SpawnWall(target, or, side);

                    sceneView.Update();
                    sceneView.Repaint();
                }
                else if (RightDown())
                {
                    RoomManager.roomManager.RemoveWall(MousePos);
                    sceneView.Update();
                    sceneView.Repaint();
                }

            }
            else if (selectedPiece == typeof(Player))
            {
                Cell target = Cell.GetFromWorldPos(MousePos);
                if (target != null)
                {
                    Indicator.transform.position = target.WorldPos();
                    if (LeftDown())
                    {
                        //SpawnPiece(selectedPiece, target);
                        SpawnPlayer(target);
                        sceneView.Update();
                        sceneView.Repaint();
                    }
                    else if (RightDown())
                    {
                        RoomManager.roomManager.RemoveTopPiece(target);
                        sceneView.Update();
                        sceneView.Repaint();
                    }
                }
            }
            else if (selectedIndex != 0)//spawn any other piece (other than wall)
            {
                Cell target = Cell.GetFromWorldPos(MousePos);
                if (target!=null) {
                    if (Indicator != null) Indicator.transform.position = target.WorldPos();
                    if (LeftDown())
                    {
                        SpawnPiece(selectedPiece, target);
                        sceneView.Update();
                        sceneView.Repaint();
                    }
                    else if (RightDown())
                    {
                        RoomManager.roomManager.RemoveTopPiece(target);
                        sceneView.Update();
                        sceneView.Repaint();
//.........这里部分代码省略.........
开发者ID:GameMakersUnion,项目名称:CubeRollersDeluxe,代码行数:101,代码来源:PuzzleMaker.cs


注:本文中的SceneView.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。