private void MouseClick(int buttonID, Vector3 position) { if (!isEditModeActive) { return; } if (Time.timeSinceLevelLoad < nexTimeToReceiveInput) { return; } if (!BIWUtils.IsPointerOverUIElement()) { HUDController.i.builderInWorldMainHud.HideExtraBtns(); } if (Utils.isCursorLocked || modeController.IsGodModeActive()) { if (buttonID == 0) { MouseClickDetected(); InputDone(); return; } outlinerController.CheckOutline(); } }
void RotateSelection(float angleToRotate) { currentYRotationAdded += angleToRotate; editionGO.transform.Rotate(Vector3.up, angleToRotate); snapGO.transform.Rotate(Vector3.up, angleToRotate); snapGO.transform.rotation = Quaternion.Euler(BIWUtils.SnapFilterEulerAngles(snapGO.transform.rotation.eulerAngles, snapRotationDegresFactor)); }
private void Awake() { mainButton.onClick.AddListener(() => OnPointerClick(dummyActionTrigger)); toggleOpenEntityListInputAction.OnTriggered += OnPointerClick; BIWUtils.ConfigureEventTrigger(inspectorButtonEventTrigger, EventTriggerType.PointerEnter, (eventData) => OnPointerEnter((PointerEventData)eventData)); BIWUtils.ConfigureEventTrigger(inspectorButtonEventTrigger, EventTriggerType.PointerExit, (eventData) => OnPointerExit()); }
private void OnDestroy() { mainButton.onClick.RemoveAllListeners(); toggleOpenEntityListInputAction.OnTriggered -= OnPointerClick; BIWUtils.RemoveEventTrigger(inspectorButtonEventTrigger, EventTriggerType.PointerEnter); BIWUtils.RemoveEventTrigger(inspectorButtonEventTrigger, EventTriggerType.PointerExit); }
public void UndoEditionGOLastStep() { if (undoGO == null || editionGO == null) return; BIWUtils.CopyGameObjectStatus(undoGO, editionGO, false, false); }
private void OnDestroy() { mainButton.onClick.RemoveAllListeners(); toggleCatalogInputAction.OnTriggered -= OnPointerClick; BIWUtils.RemoveEventTrigger(catalogButtonEventTrigger, EventTriggerType.PointerEnter); BIWUtils.RemoveEventTrigger(catalogButtonEventTrigger, EventTriggerType.PointerExit); }
public override void Update() { base.Update(); if (isPlacingNewObject) { SetEditObjectAtMouse(); } else if (isSquareMultiSelectionInputActive && isMouseDragging) { List <BIWEntity> allEntities = null; allEntities = entityHandler.GetAllEntitiesFromCurrentScene(); foreach (BIWEntity entity in allEntities) { if (!entity.rootEntity.meshRootGameObject || entity.rootEntity.meshesInfo.renderers.Length <= 0) { continue; } if (BIWUtils.IsWithInSelectionBounds(entity.rootEntity.meshesInfo.mergedBounds.center, lastMousePosition, Input.mousePosition)) { outlinerController.OutlineEntity(entity); } else { outlinerController.CancelEntityOutline(entity); } } } }
public void CheckOutline() { if (outlinerOptimizationCounter >= 10 && isOutlineCheckActive) { if (!BIWUtils.IsPointerOverUIElement() && !BIWUtils.IsPointerOverMaskElement(BIWSettings.GIZMOS_LAYER)) { BIWEntity entity = raycastController.GetEntityOnPointer(); RemoveEntitiesOutlineOutsidePointerOrUnselected(); if (entity != null && !entity.IsSelected) { OutlineEntity(entity); } } else { CancelUnselectedOutlines(); } outlinerOptimizationCounter = 0; } else { outlinerOptimizationCounter++; } }
public void SetContent(List <BIWEntity> entityList) { this.entityList = entityList; filteredList = BIWUtils.FilterEntitiesBySmartItemComponentAndActions(entityList); GenerateEntityDropdownContent(); SelectedEntity(0); }
Vector3 GetInitialCameraPosition(ParcelScene parcelScene) { Vector3 middlePoint = BIWUtils.CalculateUnityMiddlePoint(parcelScene); Vector3 direction = (parcelScene.transform.position - middlePoint).normalized; return(parcelScene.transform.position + direction * initialEagleCameraDistance + Vector3.up * initialEagleCameraHeight); }
public override void OnGUI() { base.OnGUI(); if (mouseMainBtnPressed && isSquareMultiSelectionInputActive) { var rect = BIWUtils.GetScreenRect(lastMousePosition, Input.mousePosition); BIWUtils.DrawScreenRect(rect, new Color(1f, 1f, 1f, 0.25f)); BIWUtils.DrawScreenRectBorder(rect, 1, Color.white); } }
private void Awake() { CreateSlotToDrag(); for (int i = 0; i < shortcutsButtons.Length; i++) { int buttonIndex = i; shortcutsButtons[buttonIndex].onClick.AddListener(() => QuickBarObjectSelected(buttonIndex)); } for (int i = 0; i < shortcutsEventTriggers.Length; i++) { int triggerIndex = i; BIWUtils.ConfigureEventTrigger(shortcutsEventTriggers[triggerIndex], EventTriggerType.BeginDrag, (eventData) => { BeginDragSlot(triggerIndex); }); BIWUtils.ConfigureEventTrigger(shortcutsEventTriggers[triggerIndex], EventTriggerType.Drag, (eventData) => { DragSlot(eventData, triggerIndex); }); BIWUtils.ConfigureEventTrigger(shortcutsEventTriggers[triggerIndex], EventTriggerType.EndDrag, (eventData) => { EndDragSlot(triggerIndex); }); BIWUtils.ConfigureEventTrigger(shortcutsEventTriggers[triggerIndex], EventTriggerType.Drop, (eventData) => { SetIndexToDrop(triggerIndex); if (lastIndexToBeginDrag != -1) { SceneObjectDroppedFromQuickBar(lastIndexToBeginDrag, triggerIndex, shortcutsImgs[lastIndexToBeginDrag].image.texture); CancelCurrentDragging(); } else { SceneObjectDroppedFromCatalog(eventData); } }); } quickBar1InputAction.OnTriggered += OnQuickBar1InputTriggedered; quickBar2InputAction.OnTriggered += OnQuickBar2InputTriggedered; quickBar3InputAction.OnTriggered += OnQuickBar3InputTriggedered; quickBar4InputAction.OnTriggered += OnQuickBar4InputTriggedered; quickBar5InputAction.OnTriggered += OnQuickBar5InputTriggedered; quickBar6InputAction.OnTriggered += OnQuickBar6InputTriggedered; quickBar7InputAction.OnTriggered += OnQuickBar7InputTriggedered; quickBar8InputAction.OnTriggered += OnQuickBar8InputTriggedered; quickBar9InputAction.OnTriggered += OnQuickBar9InputTriggedered; }
public IDCLEntity CreateEntityFromJSON(string entityJson) { EntityData data = BIWUtils.ConvertJSONToEntityData(entityJson); IDCLEntity newEntity = sceneToEdit.CreateEntity(data.entityId); if (data.transformComponent != null) { DCLTransform.model.position = data.transformComponent.position; DCLTransform.model.rotation = Quaternion.Euler(data.transformComponent.rotation); DCLTransform.model.scale = data.transformComponent.scale; sceneToEdit.EntityComponentCreateOrUpdateWithModel(newEntity.entityId, CLASS_ID_COMPONENT.TRANSFORM, DCLTransform.model); } foreach (ProtocolV2.GenericComponent component in data.components) { sceneToEdit.EntityComponentCreateOrUpdateWithModel(newEntity.entityId, (CLASS_ID_COMPONENT)component.componentId, component.data); } foreach (ProtocolV2.GenericComponent component in data.sharedComponents) { sceneToEdit.SharedComponentAttach(newEntity.entityId, component.classId); } if (data.nftComponent != null) { NFTShape nftShape = (NFTShape)sceneToEdit.SharedComponentCreate(data.nftComponent.id, Convert.ToInt32(CLASS_ID.NFT_SHAPE)); nftShape.model = new NFTShape.Model(); nftShape.model.color = data.nftComponent.color.ToColor(); nftShape.model.src = data.nftComponent.src; nftShape.model.assetId = data.nftComponent.assetId; sceneToEdit.SharedComponentAttach(newEntity.entityId, nftShape.id); } var convertedEntity = SetupEntityToEdit(newEntity, true); if (convertedEntity.rootEntity.TryGetSharedComponent(CLASS_ID.GLTF_SHAPE, out var gltfComponent)) { gltfComponent.CallWhenReady(convertedEntity.ShapeLoadFinish); } if (convertedEntity.rootEntity.TryGetSharedComponent(CLASS_ID.NFT_SHAPE, out var nftComponent)) { nftComponent.CallWhenReady(convertedEntity.ShapeLoadFinish); } creatorController.CreateLoadingObject(convertedEntity); EntityListChanged(); return(newEntity); }
public override void SelectedEntity(BIWEntity selectedEntity) { base.SelectedEntity(selectedEntity); initialRotation = editionGO.transform.rotation; SetObjectIfSnapOrNot(); currentYRotationAdded = 0; BIWUtils.CopyGameObjectStatus(editionGO, snapGO, false); }
private bool CanDrag() { if (!canInputBeMade || currentClickIsOnUi || BIWUtils.IsPointerOverUIElement()) { return(false); } return(true); }
public void TryLookAtEntity(IDCLEntity entity) { if (entity.meshRootGameObject == null || entity.meshesInfo == null || BIWUtils.IsBoundInsideCamera(entity.meshesInfo.mergedBounds)) { return; } LookAtEntity(entity); }
public void SetContent(SmartItemActionEvent actionEvent) { this.actionEvent = actionEvent; filteredList = BIWUtils.FilterEntitiesBySmartItemComponentAndActions(actionEvent.entityList); GenerateEntityDropdownContent(); foreach (BIWEntity entity in filteredList) { GetThumbnail(entity); } SelectedEntity(entityDropDown.value); }
public void EndMultiVoxelSelection() { List <BIWEntity> voxelEntities = biwEntityHandler.GetAllVoxelsEntities(); foreach (BIWEntity voxelEntity in voxelEntities) { if (BIWUtils.IsWithInSelectionBounds(voxelEntity.rootEntity.gameObject.transform, lastMousePosition, Input.mousePosition)) { biwEntityHandler.SelectEntity(voxelEntity); } } outlinerController.SetOutlineCheckActive(true); outlinerController.CancelAllOutlines(); }
public BIWEntity DuplicateEntity(BIWEntity entityToDuplicate) { IDCLEntity entity = SceneUtils.DuplicateEntity(sceneToEdit, entityToDuplicate.rootEntity); //Note: If the entity contains the name component or DCLLockedOnEdit, we don't want to copy them entity.RemoveSharedComponent(typeof(DCLName), false); entity.RemoveSharedComponent(typeof(DCLLockedOnEdit), false); BIWUtils.CopyGameObjectStatus(entityToDuplicate.rootEntity.gameObject, entity.gameObject, false, false); BIWEntity convertedEntity = SetupEntityToEdit(entity); NotifyEntityIsCreated(entity); EntityListChanged(); return(convertedEntity); }
private void MouseWheel(float axisValue) { if (!isEditModeActive) { return; } if (!canInputBeMade) { return; } if (!BIWUtils.IsPointerOverUIElement()) { OnMouseWheel?.Invoke(axisValue); } }
private void GetCatalog() { if (catalogAdded) { return; } if (areCatalogHeadersReady) { catalogAsyncOp = BIWUtils.MakeGetCall(BIWUrlUtils.GetUrlCatalog(), CatalogReceived, catalogCallHeaders); } else { builderInWorldBridge.AskKernelForCatalogHeaders(); } isCatalogRequested = true; }
private void EndBoundMultiSelection() { freeCameraController.SetCameraCanMove(true); List <BIWEntity> allEntities = null; allEntities = entityHandler.GetAllEntitiesFromCurrentScene(); List <BIWEntity> selectedInsideBoundsEntities = new List <BIWEntity>(); int alreadySelectedEntities = 0; if (!isMultiSelectionActive) { entityHandler.DeselectEntities(); } foreach (BIWEntity entity in allEntities) { if (entity.rootEntity.meshRootGameObject && entity.rootEntity.meshesInfo.renderers.Length > 0) { if (BIWUtils.IsWithInSelectionBounds(entity.rootEntity.meshesInfo.mergedBounds.center, lastMousePosition, Input.mousePosition) && !entity.IsLocked) { if (entity.IsSelected) { alreadySelectedEntities++; } entityHandler.SelectEntity(entity); selectedInsideBoundsEntities.Add(entity); } } } if (selectedInsideBoundsEntities.Count == alreadySelectedEntities && alreadySelectedEntities > 0) { foreach (BIWEntity entity in selectedInsideBoundsEntities) { entityHandler.DeselectEntity(entity); } } outlinerController.CancelAllOutlines(); }
private void MouseDown(int buttonId, Vector3 mousePosition) { if (!isEditModeActive) { return; } lastTimeMouseDown = Time.unscaledTime; lastMousePosition = mousePosition; currentClickIsOnUi = BIWUtils.IsPointerOverUIElement(); if (!canInputBeMade) { return; } if (!currentClickIsOnUi) { OnMouseDown?.Invoke(buttonId, mousePosition); } }
public override void LateUpdate() { base.LateUpdate(); if (selectedEntities.Count == 0 || isMultiSelectionActive) { return; } if (isSnapActive) { if (snapObjectAlreadyMoved) { Vector3 objectPosition = snapGO.transform.position; Vector3 eulerRotation = snapGO.transform.rotation.eulerAngles; float currentSnapFactor = snapFactor; objectPosition.x = Mathf.RoundToInt(objectPosition.x / currentSnapFactor) * currentSnapFactor; objectPosition.y = Mathf.RoundToInt(objectPosition.y / currentSnapFactor) * currentSnapFactor; objectPosition.z = Mathf.RoundToInt(objectPosition.z / currentSnapFactor) * currentSnapFactor; eulerRotation.y = snapRotationDegresFactor * Mathf.FloorToInt((eulerRotation.y % snapRotationDegresFactor)); Quaternion destinationRotation = Quaternion.AngleAxis(currentYRotationAdded, Vector3.up); editionGO.transform.rotation = initialRotation * destinationRotation; editionGO.transform.position = objectPosition; } else if (Vector3.Distance(snapGO.transform.position, editionGO.transform.position) >= snapDistanceToActivateMovement) { BIWUtils.CopyGameObjectStatus(editionGO, snapGO, false); snapObjectAlreadyMoved = true; SetEditObjectParent(); } } else { Vector3 pointToLookAt = Camera.main.transform.position; pointToLookAt.y = editionGO.transform.position.y; Quaternion lookOnLook = Quaternion.LookRotation(editionGO.transform.position - pointToLookAt); freeMovementGO.transform.rotation = lookOnLook; } }
void OnInputMouseDown(int buttonID, Vector3 position) { lastMousePosition = position; if (buttonID == 1) { mouseSecondaryBtnPressed = true; freeCameraController.StartDectectingMovement(); } if (buttonID != 0) { return; } dragStartedPoint = raycastController.GetFloorPointAtMouse(position); if (isSnapActive) { dragStartedPoint.x = Mathf.Round(dragStartedPoint.x); dragStartedPoint.z = Mathf.Round(dragStartedPoint.z); } if (isPlacingNewObject) { return; } var entity = raycastController.GetEntityOnPointer(); if ((entity == null || (entity != null && !entity.IsSelected)) && !BIWUtils.IsPointerOverMaskElement(BIWSettings.GIZMOS_LAYER)) { isSquareMultiSelectionInputActive = true; outlinerController.SetOutlineCheckActive(false); } mouseMainBtnPressed = true; freeCameraController.SetCameraCanMove(false); }
private void OnInputMouseDrag(int buttonId, Vector3 mousePosition, float axisX, float axisY) { if (Vector3.Distance(lastMousePosition, mousePosition) <= BIWSettings.MOUSE_THRESHOLD_FOR_DRAG && !isMouseDragging) { return; } isMouseDragging = true; if (buttonId != 0 || selectedEntities.Count <= 0 || BIWUtils.IsPointerOverMaskElement(BIWSettings.GIZMOS_LAYER) || isSquareMultiSelectionInputActive) { return; } if (!isDraggingStarted) { StarDraggingSelectedEntities(); } if (canDragSelectedEntities) { Vector3 currentPoint = raycastController.GetFloorPointAtMouse(mousePosition); Vector3 initialEntityPosition = editionGO.transform.position; if (isSnapActive) { currentPoint = GetPositionRoundedToSnapFactor(currentPoint); initialEntityPosition = GetPositionRoundedToSnapFactor(initialEntityPosition); } Vector3 move = currentPoint - dragStartedPoint; Vector3 destination = initialEntityPosition + move; editionGO.transform.position = destination; dragStartedPoint = currentPoint; } }
public void ToggleCatalogExpanse() { if (isCatalogExpanded) { BIWUtils.CopyRectTransform(panelRT, panelMinSizeRT); BIWUtils.CopyRectTransform(headerRT, headerMinSizeRT); BIWUtils.CopyRectTransform(searchBarRT, searchBarMinSizeRT); BIWUtils.CopyRectTransform(assetPackRT, assetPackMinSizeRT); BIWUtils.CopyRectTransform(categoryRT, assetPackMinSizeRT); AudioScriptableObjects.dialogClose.Play(); } else { BIWUtils.CopyRectTransform(panelRT, panelMaxSizeRT); BIWUtils.CopyRectTransform(headerRT, headerMaxSizeRT); BIWUtils.CopyRectTransform(searchBarRT, searchBarMaxSizeRT); BIWUtils.CopyRectTransform(assetPackRT, assetPackMaxSizeRT); BIWUtils.CopyRectTransform(categoryRT, assetPackMaxSizeRT); AudioScriptableObjects.dialogOpen.Play(); } isCatalogExpanded = !isCatalogExpanded; }
private void MouseUp(int buttonId, Vector3 mousePosition) { if (!isEditModeActive) { return; } if (currentClickIsOnUi) { OnMouseClickOnUI?.Invoke(buttonId, mousePosition); currentClickIsOnUi = false; return; } if (!canInputBeMade) { return; } if (!BIWUtils.IsPointerOverUIElement()) { OnMouseUp?.Invoke(buttonId, mousePosition); if (Vector3.Distance(mousePosition, lastMousePosition) >= MOVEMENT_CLICK_THRESHOLD) { return; } if (Time.unscaledTime >= lastTimeMouseDown + MS_CLICK_THRESHOLD / 1000) { return; } OnMouseClick?.Invoke(buttonId, mousePosition); } else { OnMouseUpOnUI?.Invoke(buttonId, mousePosition); } }
private void OnDestroy() { for (int i = 0; i < shortcutsButtons.Length; i++) { int buttonIndex = i; shortcutsButtons[buttonIndex].onClick.RemoveAllListeners(); } for (int i = 0; i < shortcutsEventTriggers.Length; i++) { int triggerIndex = i; BIWUtils.RemoveEventTrigger(shortcutsEventTriggers[triggerIndex], EventTriggerType.Drop); } quickBar1InputAction.OnTriggered -= OnQuickBar1InputTriggedered; quickBar2InputAction.OnTriggered -= OnQuickBar2InputTriggedered; quickBar3InputAction.OnTriggered -= OnQuickBar3InputTriggedered; quickBar4InputAction.OnTriggered -= OnQuickBar4InputTriggedered; quickBar5InputAction.OnTriggered -= OnQuickBar5InputTriggedered; quickBar6InputAction.OnTriggered -= OnQuickBar6InputTriggedered; quickBar7InputAction.OnTriggered -= OnQuickBar7InputTriggedered; quickBar8InputAction.OnTriggered -= OnQuickBar8InputTriggedered; quickBar9InputAction.OnTriggered -= OnQuickBar9InputTriggedered; }
public virtual void SelectedEntity(BIWEntity selectedEntity) { CenterGameObjectToEdit(); BIWUtils.CopyGameObjectStatus(editionGO, undoGO, false, false); }