Beispiel #1
0
        internal void Create(ref Vector3[] boundsCorners, Transform parent, bool isFlattened)
        {
            // create corners
            for (int i = 0; i < boundsCorners.Length; ++i)
            {
                GameObject corner = new GameObject
                {
                    name = "corner_" + i.ToString()
                };
                corner.transform.parent        = parent;
                corner.transform.localPosition = boundsCorners[i];

                GameObject visualsScale = new GameObject();
                visualsScale.name                    = "visualsScale";
                visualsScale.transform.parent        = corner.transform;
                visualsScale.transform.localPosition = Vector3.zero;

                // Compute mirroring scale
                {
                    Vector3 p = boundsCorners[i];
                    visualsScale.transform.localScale = new Vector3(Mathf.Sign(p[0]), Mathf.Sign(p[1]), Mathf.Sign(p[2]));
                }

                Bounds visualBounds = CreateVisual(visualsScale, isFlattened);
                var    invScale     = visualBounds.size.x == 0.0f ? 0.0f : config.HandleSize / visualBounds.size.x;
                VisualUtils.AddComponentsToAffordance(corner, new Bounds(visualBounds.center * invScale, visualBounds.size * invScale),
                                                      HandlePrefabCollider.Box, CursorContextInfo.CursorAction.Scale, config.ColliderPadding, parent, config.DrawTetherWhenManipulating);
                handles.Add(corner.transform);
            }

            VisualUtils.HandleIgnoreCollider(config.HandlesIgnoreCollider, handles);
            objectsChangedEvent.Invoke(this);
        }
        private void CreateHandles(Transform parent)
        {
            for (int i = 0; i < HandlePositions.Length; ++i)
            {
                GameObject handle = new GameObject();
                handle.name = HandlePositionDescription + "_" + i.ToString();
                handle.transform.position = HandlePositions[i];
                handle.transform.parent   = parent;

                Bounds midpointBounds = CreateVisual(i, handle);
                float  maxDim         = VisualUtils.GetMaxComponent(midpointBounds.size);
                float  invScale       = maxDim == 0.0f ? 0.0f : config.HandleSize / maxDim;
                VisualUtils.AddComponentsToAffordance(handle, new Bounds(midpointBounds.center * invScale, midpointBounds.size * invScale),
                                                      config.HandlePrefabColliderType, CursorContextInfo.CursorAction.Rotate, config.ColliderPadding, parent, config.DrawTetherWhenManipulating);

                handles.Add(handle.transform);
            }

            VisualUtils.HandleIgnoreCollider(config.HandlesIgnoreCollider, handles);

            objectsChangedEvent.Invoke(this);
        }
Beispiel #3
0
        internal void Create(ref Vector3[] boundsCorners, Transform parent, bool isFlattened)
        {
            CalculateHandlePositions(ref boundsCorners);

            // create corners
            for (int i = 0; i < boundsCorners.Length; ++i)
            {
                GameObject corner = new GameObject
                {
                    name = "corner_" + i.ToString()
                };
                corner.transform.parent        = parent;
                corner.transform.localPosition = HandlePositions[i];

                Bounds visualBounds = CreateVisual(i, corner, isFlattened);
                var    invScale     = visualBounds.size.x == 0.0f ? 0.0f : config.HandleSize / visualBounds.size.x;
                VisualUtils.AddComponentsToAffordance(corner, new Bounds(visualBounds.center * invScale, visualBounds.size * invScale),
                                                      HandlePrefabCollider.Box, CursorContextInfo.CursorAction.Scale, config.ColliderPadding, parent, config.DrawTetherWhenManipulating);
                handles.Add(corner.transform);
            }

            VisualUtils.HandleIgnoreCollider(config.HandlesIgnoreCollider, handles);
            objectsChangedEvent.Invoke(this);
        }
 private void HandlesIgnoreConfigCollider(bool ignore)
 {
     VisualUtils.HandleIgnoreCollider(BaseConfig.HandlesIgnoreCollider, handles, ignore);
 }