コード例 #1
0
        protected override void OnInspectorGUIInsertion()
        {
            EditorGUILayout.PropertyField(surfaceType);
            EditorGUILayout.PropertyField(orientType);
            EditorGUILayout.PropertyField(layout);
            if ((ObjectOrientationSurfaceType)surfaceType.enumValueIndex == ObjectOrientationSurfaceType.Plane)
            {
                EditorGUILayout.PropertyField(distance);
            }
            else
            {
                EditorGUILayout.PropertyField(radius);
                EditorGUILayout.PropertyField(radialRange);
            }

            LayoutOrder layoutTypeIndex = (LayoutOrder)layout.enumValueIndex;

            if (layoutTypeIndex != LayoutOrder.Horizontal && layoutTypeIndex != LayoutOrder.Vertical)
            {
                EditorGUILayout.PropertyField(rows);
            }
            if (layoutTypeIndex != LayoutOrder.Vertical)
            {
                EditorGUILayout.PropertyField(cellWidth);
            }
            if (layoutTypeIndex != LayoutOrder.Horizontal)
            {
                EditorGUILayout.PropertyField(cellHeight);
            }
        }
コード例 #2
0
        protected override void OnInspectorGUIInsertion()
        {
            EditorGUILayout.PropertyField(surfaceType);
            EditorGUILayout.PropertyField(orientType);
            EditorGUILayout.PropertyField(layout);



            LayoutOrder layoutTypeIndex = (LayoutOrder)layout.intValue;

            if (layoutTypeIndex == LayoutOrder.ColumnThenRow)
            {
                EditorGUILayout.HelpBox("ColumnThenRow will lay out content first horizontally (by column), then vertically (by row). NumColumns specifies number of columns per row.", MessageType.Info);
                EditorGUILayout.PropertyField(cols, new GUIContent("Num Columns", "Number of columns per row."));
                EditorGUILayout.PropertyField(columnAlignment);
            }
            else if (layoutTypeIndex == LayoutOrder.RowThenColumn)
            {
                EditorGUILayout.HelpBox("RowThenColumns will lay out content first vertically (by row), then horizontally (by column). NumRows specifies number of rows per column.", MessageType.Info);
                EditorGUILayout.PropertyField(rows, new GUIContent("Num Rows", "Number of rows per column."));
                EditorGUILayout.PropertyField(rowAlignment);
            }
            else
            {
                // do not show rows / cols field
            }

            if (layoutTypeIndex != LayoutOrder.Vertical)
            {
                EditorGUILayout.PropertyField(cellWidth);
            }
            if (layoutTypeIndex != LayoutOrder.Horizontal)
            {
                EditorGUILayout.PropertyField(cellHeight);
            }

            ObjectOrientationSurfaceType surfaceTypeIndex = (ObjectOrientationSurfaceType)surfaceType.intValue;

            if (surfaceTypeIndex == ObjectOrientationSurfaceType.Plane)
            {
                EditorGUILayout.PropertyField(distance, new GUIContent("Distance from parent", "Distance from parent object's origin"));
            }
            else
            {
                EditorGUILayout.PropertyField(radius);
                EditorGUILayout.PropertyField(radialRange);
            }

            if (surfaceTypeIndex != ObjectOrientationSurfaceType.Radial)
            {
                // layout anchor has no effect on radial layout, it is always at center.
                EditorGUILayout.PropertyField(anchor);
            }

            if ((LayoutAnchor)anchor.intValue != LayoutAnchor.MiddleCenter)
            {
                EditorGUILayout.PropertyField(anchorAlongAxis);
            }
        }
コード例 #3
0
        protected void ResolveGridLayout(Vector3[] grid, LayoutOrder order)
        {
            int cellCounter = 0;
            int iMax, jMax;

            switch (order)
            {
            case LayoutOrder.RowThenColumn:
                iMax = Rows;
                jMax = Columns;
                break;

            case LayoutOrder.ColumnThenRow:
                iMax = Columns;
                jMax = Rows;
                break;

            case LayoutOrder.Vertical:
                iMax = 1;
                jMax = NodeList.Count;
                break;

            case LayoutOrder.Horizontal:
                iMax = NodeList.Count;
                jMax = 1;
                break;

            default:
                iMax = Mathf.CeilToInt((float)NodeList.Count / rows);
                jMax = rows;
                break;
            }

            float startOffsetX = (iMax * 0.5f) * CellWidth;
            float startOffsetY = (jMax * 0.5f) * CellHeight;

            for (int i = 0; i < iMax; i++)
            {
                for (int j = 0; j < jMax; j++)
                {
                    if (cellCounter < NodeList.Count)
                    {
                        grid[cellCounter].Set((-startOffsetX + (i * CellWidth) + HalfCell.x) + NodeList[cellCounter].Offset.x,
                                              (startOffsetY - (j * CellHeight) - HalfCell.y) + NodeList[cellCounter].Offset.y,
                                              0.0f);
                    }
                    cellCounter++;
                }
            }
        }
コード例 #4
0
        protected override void OnInspectorGUIInsertion()
        {
            EditorGUILayout.PropertyField(surfaceType);
            EditorGUILayout.PropertyField(orientType);
            EditorGUILayout.PropertyField(layout);



            LayoutOrder layoutTypeIndex = (LayoutOrder)layout.enumValueIndex;

            if (layoutTypeIndex == LayoutOrder.ColumnThenRow)
            {
                EditorGUILayout.PropertyField(cols, new GUIContent("Num Columns", "Number of columns per row."));
            }
            else if (layoutTypeIndex == LayoutOrder.RowThenColumn)
            {
                EditorGUILayout.PropertyField(rows, new GUIContent("Num Rows", "Number of rows per column."));
            }
            else
            {
                // do not show rows / cols field
            }

            if (layoutTypeIndex != LayoutOrder.Vertical)
            {
                EditorGUILayout.PropertyField(cellWidth);
            }
            if (layoutTypeIndex != LayoutOrder.Horizontal)
            {
                EditorGUILayout.PropertyField(cellHeight);
            }

            ObjectOrientationSurfaceType surfaceTypeIndex = (ObjectOrientationSurfaceType)surfaceType.enumValueIndex;

            if (surfaceTypeIndex == ObjectOrientationSurfaceType.Plane)
            {
                EditorGUILayout.PropertyField(distance, new GUIContent("Distance from parent", "Distance from parent object's origin"));
            }
            else
            {
                EditorGUILayout.PropertyField(radius);
                EditorGUILayout.PropertyField(radialRange);
            }

            if (surfaceTypeIndex != ObjectOrientationSurfaceType.Radial)
            {
                // layout anchor has no effect on radial layout, it is always at center.
                EditorGUILayout.PropertyField(anchor);
            }
        }
コード例 #5
0
        protected void ResolveGridLayout(Vector3[] grid, LayoutOrder order)
        {
            int cellCounter = 0;
            int xMax, yMax;

            switch (order)
            {
            case LayoutOrder.RowThenColumn:
                xMax = Columns;
                yMax = Rows;
                break;

            case LayoutOrder.ColumnThenRow:
                xMax = Columns;
                yMax = Rows;
                break;

            case LayoutOrder.Vertical:
                xMax = 1;
                yMax = NodeList.Count;
                break;

            case LayoutOrder.Horizontal:
                xMax = NodeList.Count;
                yMax = 1;
                break;

            default:
                xMax = Mathf.CeilToInt((float)NodeList.Count / rows);
                yMax = rows;
                break;
            }

            float startOffsetX = (xMax * 0.5f) * CellWidth;

            if (anchor == LayoutAnchor.BottomLeft || anchor == LayoutAnchor.UpperLeft || anchor == LayoutAnchor.MiddleLeft)
            {
                startOffsetX = anchorAlongAxis ? 0.5f * CellWidth : 0;
            }
            else if (anchor == LayoutAnchor.BottomRight || anchor == LayoutAnchor.UpperRight || anchor == LayoutAnchor.MiddleRight)
            {
                startOffsetX = anchorAlongAxis ? (xMax - 0.5f) * CellWidth : xMax * CellWidth;
            }

            float startOffsetY = (yMax * 0.5f) * CellHeight;

            if (anchor == LayoutAnchor.UpperLeft || anchor == LayoutAnchor.UpperCenter || anchor == LayoutAnchor.UpperRight)
            {
                startOffsetY = anchorAlongAxis ? 0.5f * CellHeight: 0;
            }
            else if (anchor == LayoutAnchor.BottomLeft || anchor == LayoutAnchor.BottomCenter || anchor == LayoutAnchor.BottomRight)
            {
                startOffsetY = anchorAlongAxis ? (yMax - 0.5f) * CellHeight : yMax * CellHeight;
            }
            float alignmentOffsetX = 0;
            float alignmentOffsetY = 0;

            if (layout == LayoutOrder.ColumnThenRow)
            {
                for (int y = 0; y < yMax; y++)
                {
                    for (int x = 0; x < xMax; x++)
                    {
                        if (y == yMax - 1)
                        {
                            switch (ColumnAlignment)
                            {
                            case LayoutHorizontalAlignment.Left:
                                alignmentOffsetX = 0;
                                break;

                            case LayoutHorizontalAlignment.Center:
                                alignmentOffsetX = CellWidth * ((xMax - (NodeList.Count % xMax)) % xMax) * 0.5f;
                                break;

                            case LayoutHorizontalAlignment.Right:
                                alignmentOffsetX = CellWidth * ((xMax - (NodeList.Count % xMax)) % xMax);
                                break;
                            }
                        }

                        if (cellCounter < NodeList.Count)
                        {
                            grid[cellCounter].Set((-startOffsetX + (x * CellWidth) + HalfCell.x) + NodeList[cellCounter].Offset.x + alignmentOffsetX,
                                                  (startOffsetY - (y * CellHeight) - HalfCell.y) + NodeList[cellCounter].Offset.y + alignmentOffsetY,
                                                  0.0f);
                        }
                        cellCounter++;
                    }
                }
            }
            else
            {
                for (int x = 0; x < xMax; x++)
                {
                    for (int y = 0; y < yMax; y++)
                    {
                        if (x == xMax - 1)
                        {
                            switch (RowAlignment)
                            {
                            case LayoutVerticalAlignment.Top:
                                alignmentOffsetY = 0;
                                break;

                            case LayoutVerticalAlignment.Middle:
                                alignmentOffsetY = -CellHeight * ((yMax - (NodeList.Count % yMax)) % yMax) * 0.5f;
                                break;

                            case LayoutVerticalAlignment.Bottom:
                                alignmentOffsetY = -CellHeight * ((yMax - (NodeList.Count % yMax)) % yMax);
                                break;
                            }
                        }

                        if (cellCounter < NodeList.Count)
                        {
                            grid[cellCounter].Set((-startOffsetX + (x * CellWidth) + HalfCell.x) + NodeList[cellCounter].Offset.x + alignmentOffsetX,
                                                  (startOffsetY - (y * CellHeight) - HalfCell.y) + NodeList[cellCounter].Offset.y + alignmentOffsetY,
                                                  0.0f);
                        }
                        cellCounter++;
                    }
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// Declare this class or struct to be able to serialize to binary format
 /// </summary>
 /// <param name="layout">The target layout</param>
 public BinaryFormatAttribute(LayoutOrder layout)
 {
     Layout = layout;
 }
        protected void ResolveGridLayout(Vector3[] grid, LayoutOrder order)
        {
            int cellCounter = 0;
            int xMax, yMax;

            switch (order)
            {
            case LayoutOrder.RowThenColumn:
                xMax = Columns;
                yMax = Rows;
                break;

            case LayoutOrder.ColumnThenRow:
                xMax = Columns;
                yMax = Rows;
                break;

            case LayoutOrder.Vertical:
                xMax = 1;
                yMax = NodeList.Count;
                break;

            case LayoutOrder.Horizontal:
                xMax = NodeList.Count;
                yMax = 1;
                break;

            default:
                xMax = Mathf.CeilToInt((float)NodeList.Count / rows);
                yMax = rows;
                break;
            }

            float startOffsetX = (xMax * 0.5f) * CellWidth;

            if (anchor == LayoutAnchor.BottomLeft || anchor == LayoutAnchor.UpperLeft || anchor == LayoutAnchor.MiddleLeft)
            {
                startOffsetX = 0;
            }
            else if (anchor == LayoutAnchor.BottomRight || anchor == LayoutAnchor.UpperRight || anchor == LayoutAnchor.MiddleRight)
            {
                startOffsetX = xMax * CellWidth;
            }

            float startOffsetY = (yMax * 0.5f) * CellHeight;

            if (anchor == LayoutAnchor.UpperLeft || anchor == LayoutAnchor.UpperCenter || anchor == LayoutAnchor.UpperRight)
            {
                startOffsetY = 0;
            }
            else if (anchor == LayoutAnchor.BottomLeft || anchor == LayoutAnchor.BottomCenter || anchor == LayoutAnchor.BottomRight)
            {
                startOffsetY = yMax * CellHeight;
            }

            if (layout == LayoutOrder.ColumnThenRow)
            {
                for (int y = 0; y < yMax; y++)
                {
                    for (int x = 0; x < xMax; x++)
                    {
                        {
                            if (cellCounter < NodeList.Count)
                            {
                                grid[cellCounter].Set((-startOffsetX + (x * CellWidth) + HalfCell.x) + NodeList[cellCounter].Offset.x,
                                                      (startOffsetY - (y * CellHeight) - HalfCell.y) + NodeList[cellCounter].Offset.y,
                                                      0.0f);
                            }
                            cellCounter++;
                        }
                    }
                }
            }
            else
            {
                for (int x = 0; x < xMax; x++)
                {
                    for (int y = 0; y < yMax; y++)
                    {
                        if (cellCounter < NodeList.Count)
                        {
                            grid[cellCounter].Set((-startOffsetX + (x * CellWidth) + HalfCell.x) + NodeList[cellCounter].Offset.x,
                                                  (startOffsetY - (y * CellHeight) - HalfCell.y) + NodeList[cellCounter].Offset.y,
                                                  0.0f);
                        }
                        cellCounter++;
                    }
                }
            }
        }
コード例 #8
0
        protected void ResolveGridLayout(Vector3[] grid, float offsetX, float offsetY, LayoutOrder order)
        {
            int   cellCounter = 0;
            float iMax;
            float jMax;

            if (order == LayoutOrder.RowThenColumn)
            {
                iMax = Rows;
                jMax = Columns;
            }
            else
            {
                iMax = Columns;
                jMax = Rows;
            }

            for (int i = 0; i < iMax; i++)
            {
                for (int j = 0; j < jMax; j++)
                {
                    if (cellCounter < NodeList.Count)
                    {
                        grid[cellCounter].Set(((i * CellWidth) - offsetX + HalfCell.x) + NodeList[cellCounter].Offset.x,
                                              (-(j * CellHeight) + offsetY - HalfCell.y) + NodeList[cellCounter].Offset.y,
                                              0.0f);
                    }
                    cellCounter++;
                }
            }
        }
コード例 #9
0
 public IndexOrderSelector(IDiagnosticReporter diagnostic, LayoutOrder order)
 {
     _declaredOrder = order;
     _diagnostic    = diagnostic;
 }