public override void OnValidatedBeginDrag(PointerEventData eventData) { if (ModeManager.Instance.PrimaryMode == ModeManager.PrimaryModes.Textures && ModeManager.Instance.SecondaryMode == ModeManager.SecondaryModes.Editing) { // Note: Polygon surfaces have swapped UVs, so swap them here var startingUVs = DataSource == LevelEntity_Polygon.DataSources.Floor ? new Vector2(ParentPolygon.NativeObject.FloorOrigin.Y, ParentPolygon.NativeObject.FloorOrigin.X) : new Vector2(ParentPolygon.NativeObject.CeilingOrigin.Y, ParentPolygon.NativeObject.CeilingOrigin.X); var startingPosition = eventData.pointerPressRaycast.worldPosition; // Even for floor normals, use down here, because floors have U-flipped UVs var surfaceWorldNormal = Vector3.down; var textureWorldUp = Vector3.left; uvDragPlane = new UVPlanarDrag(startingUVs, startingPosition, surfaceWorldNormal, textureWorldUp); if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { alignmentGroupedPolygons.Clear(); var commonElevation = DataSource == LevelEntity_Polygon.DataSources.Floor ? ParentPolygon.NativeObject.FloorHeight : ParentPolygon.NativeObject.CeilingHeight; var commonShapeDescriptor = DataSource == LevelEntity_Polygon.DataSources.Floor ? ParentPolygon.NativeObject.FloorTexture : ParentPolygon.NativeObject.CeilingTexture; CollectSimilarAdjacentPolygons(ParentPolygon, commonElevation, commonShapeDescriptor); } } else { return; } InspectorPanel.Instance.RefreshAllInspectors(); }
public override void OnValidatedEndDrag(PointerEventData eventData) { if (uvDragPlane != null && ModeManager.Instance.PrimaryMode == ModeManager.PrimaryModes.Textures && ModeManager.Instance.SecondaryMode == ModeManager.SecondaryModes.Editing) { uvDragPlane = null; if (SurfaceBatchingManager.BatchingEnabled) { SurfaceBatchingManager.Instance.MergeAllBatches(); } alignmentGroupedPolygons.Clear(); } else { return; } InspectorPanel.Instance.RefreshAllInspectors(); }