示例#1
0
        public void ApplySnap(bool ApplyToChildren)
        {
            if (ParentScene != null && ParentScene.GetType().IsSubclassOf(typeof(Basic2DScene)))
            {
                Basic2DScene s = (Basic2DScene)ParentScene;
                if (s.GridSize != null)
                {
                    Vector2 GridSize = s.GridSize.get();
                    Vector2 Pos      = Position.get();

                    Position.set(new Vector2((float)Math.Round(Position.get().X / s.GridSize.get().X),
                                             (float)Math.Round(Position.get().Y / s.GridSize.get().Y)) * s.GridSize.get());
                }
            }

            if (ApplyToChildren)
            {
                foreach (GameObject g in HierarchyChildren)
#if EDITOR && WINDOWS
                { if (!ParentLevel.LevelForEditing || !g.EditorSelected)
#endif
                { if (g.GetType().IsSubclassOf(typeof(Basic2DObject)))
                  {
                      Basic2DObject b = (Basic2DObject)g;
                      b.ApplySnap(true);
                  }
                }
            }
        }
 public void SnapSelected()
 {
     foreach (GameObject g in SelectedGameObjects)
     {
         if (g.GetType().IsSubclassOf(typeof(Basic2DObject)))
         {
             Basic2DObject b = (Basic2DObject)g;
             b.ApplySnap(false);
         }
     }
 }