コード例 #1
0
        public override void OnValidatedDrag(PointerEventData eventData)
        {
            if (uvDragPlane != null &&
                ModeManager.Instance.PrimaryMode == ModeManager.PrimaryModes.Textures &&
                ModeManager.Instance.SecondaryMode == ModeManager.SecondaryModes.Editing)
            {
                var screenPosition = new Vector3(eventData.pointerCurrentRaycast.screenPosition.x,
                                                 eventData.pointerCurrentRaycast.screenPosition.y,
                                                 0f);

                var pointerRay = Camera.main.ScreenPointToRay(screenPosition);

                var newUVOffset = uvDragPlane.UVDraggedPosition(pointerRay);

                ParentSide.SetOffset(DataSource,
                                     (short)newUVOffset.x,
                                     (short)newUVOffset.y,
                                     rebatch: false);

                foreach (var alignmentGroupee in alignmentGroup)
                {
                    AlignDestinationToSource(alignmentGroupee.SourceSide,
                                             alignmentGroupee.SourceDataSource,
                                             alignmentGroupee.DestinationSide,
                                             alignmentGroupee.DestinationDataSource,
                                             alignmentGroupee.DestinationFlowsOutward,
                                             alignmentGroupee.DestinationIsLeftOfSource,
                                             rebatch: false);
                }
            }
            else
            {
                return;
            }

            InspectorPanel.Instance.RefreshAllInspectors();
        }
コード例 #2
0
        private void AlignDestinationToSource(LevelEntity_Side sourceSide, LevelEntity_Side.DataSources sourceDataSource, LevelEntity_Side destinationSide, LevelEntity_Side.DataSources destinationDataSource, bool destinationFlowsOutward, bool destinationIsLeftOfSource, bool rebatch)
        {
            short sourceX;
            short sourceY;
            short destinationHeight;
            short sourceHeight;

            switch (destinationDataSource)
            {
            case LevelEntity_Side.DataSources.Primary:
                destinationHeight = destinationSide.PrimaryHighElevation;
                break;

            case LevelEntity_Side.DataSources.Secondary:
                destinationHeight = destinationSide.SecondaryHighElevation;
                break;

            case LevelEntity_Side.DataSources.Transparent:
                destinationHeight = destinationSide.TransparentHighElevation;
                break;

            default:
                return;
            }

            switch (sourceDataSource)
            {
            case LevelEntity_Side.DataSources.Primary:
                sourceX = sourceSide.NativeObject.Primary.X;
                sourceY = sourceSide.NativeObject.Primary.Y;

                sourceHeight = sourceSide.PrimaryHighElevation;

                break;

            case LevelEntity_Side.DataSources.Secondary:
                sourceX = sourceSide.NativeObject.Secondary.X;
                sourceY = sourceSide.NativeObject.Secondary.Y;

                sourceHeight = sourceSide.SecondaryHighElevation;

                break;

            case LevelEntity_Side.DataSources.Transparent:
                sourceX = sourceSide.NativeObject.Transparent.X;
                sourceY = sourceSide.NativeObject.Transparent.Y;

                sourceHeight = sourceSide.TransparentHighElevation;

                break;

            default:
                return;
            }

            short horizontalOffset = destinationIsLeftOfSource ?
                                     (short)-LevelEntity_Level.Instance.Lines[destinationSide.NativeObject.LineIndex].NativeObject.Length :
                                     LevelEntity_Level.Instance.Lines[sourceSide.NativeObject.LineIndex].NativeObject.Length;

            short newX = (short)(sourceX + horizontalOffset);
            short newY = (short)(sourceHeight - destinationHeight + sourceY);

            destinationSide.SetOffset(destinationDataSource,
                                      newX,
                                      newY,
                                      rebatch);
        }