Exemplo n.º 1
0
        private IItemMainRenderableAuthoring FindParentAuthoring()
        {
            IItemMainRenderableAuthoring ma = null;
            var go = gameObject;

            // search on parent
            if (go.transform.parent != null)
            {
                ma = go.transform.parent.GetComponent <IItemMainRenderableAuthoring>();
            }

            if (ma is MonoBehaviour mb && mb.GetComponent <TableAuthoring>() != null)
            {
                return(null);
            }
            if (ma != null)
            {
                return(ma);
            }

            // search on grand parent
            if (go.transform.parent.transform.parent != null)
            {
                ma = go.transform.parent.transform.parent.GetComponent <IItemMainRenderableAuthoring>();
            }

            if (ma is MonoBehaviour mb2 && mb2.GetComponent <TableAuthoring>() != null)
            {
                return(null);
            }

            return(ma);
        }
Exemplo n.º 2
0
        protected virtual void OnEnable()
        {
            _transform = target as Transform;

            // use default inspector. we do that when no vpe-authoring items are selected.
            var useDefault = true;

            // loop through selected objects
            foreach (var t in targets)
            {
                // must be main but not the table itself
                var item = (t as Transform)?.GetComponent <IItemMainRenderableAuthoring>();
                useDefault = useDefault && (t as Transform)?.GetComponent <IItemAuthoring>() == null;
                if (item != null && !(item is TableAuthoring))
                {
                    if (_primaryItem == null)
                    {
                        _primaryItem  = item;
                        _positionType = item.EditorPositionType;
                        _rotationType = item.EditorRotationType;
                        _scaleType    = item.EditorScaleType;
                    }
                    else
                    {
                        // only transform on axes supported by all
                        if (item.EditorPositionType < _positionType)
                        {
                            _positionType = item.EditorPositionType;
                        }
                        if (item.EditorRotationType < _rotationType)
                        {
                            _rotationType = item.EditorRotationType;
                        }
                        if (item.EditorScaleType < _scaleType)
                        {
                            _scaleType = item.EditorScaleType;
                        }
                        _secondaryItems.Add(new SecondaryItem {
                            Transform = t as Transform,
                            Item      = item,
                            Offset    = item.GetEditorPosition() - _primaryItem.GetEditorPosition(),
                        });
                    }
                }
            }
            if (useDefault)
            {
                _defaultEditor = CreateEditor(targets, Type.GetType("UnityEditor.TransformInspector, UnityEditor"));
            }
        }