private IItemMainAuthoring FindParentAuthoring() { IItemMainAuthoring ma = null; var go = gameObject; // search on parent if (go.transform.parent != null) { ma = go.transform.parent.GetComponent <IItemMainAuthoring>(); } 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 <IItemMainAuthoring>(); } if (ma is MonoBehaviour mb2 && mb2.GetComponent <TableAuthoring>() != null) { return(null); } return(ma); }
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 <IItemMainAuthoring>(); 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")); } }
public ConvertedItem(IItemMainAuthoring mainAuthoring, IEnumerable <IItemMeshAuthoring> meshAuthoring, IItemColliderAuthoring colliderAuthoring) { MainAuthoring = mainAuthoring; MeshAuthoring = meshAuthoring; ColliderAuthoring = colliderAuthoring; }
public ConvertedItem(IItemMainAuthoring mainAuthoring) { MainAuthoring = mainAuthoring; MeshAuthoring = new IItemMeshAuthoring[0]; ColliderAuthoring = null; }