Exemple #1
0
        public override void OnClick(SelectableBrick brick, PointerEventData pointerEventData)
        {
            if (cursorOverPoint)
            {
                MeasureToolVisualizer.instance.SelectVertex(currentWorldPoint);
            }

            amountOfPoints++;
            if (amountOfPoints == 3)
            {
                amountOfPoints = 2;
                points[0]      = points[1];
                objects[0]     = objects[1];
                points[1]      = currentWorldPoint;
                objects[1]     = brick.gameObject;
            }
            else
            {
                points[amountOfPoints - 1]  = currentWorldPoint;
                objects[amountOfPoints - 1] = brick.gameObject;
            }

            if (joinButton != null)
            {
                joinButton.gameObject.SetActive(amountOfPoints == 2 && objects[0] != objects[1]);
            }
        }
Exemple #2
0
        public override void OnClick(SelectableBrick brick, PointerEventData pointerEventData)
        {
            if (!isDragging)
            {
                var bricks = GetSelected(brick);

#if UNITY_STANDALONE
#if UNITY_STANDALONE_WIN
                if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
#endif
#if UNITY_STANDALONE_LINUX
                if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
#endif
#if UNITY_STANDALONE_OSX
                if (Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand))
#endif
                SelectionManager.instance.Add(bricks);
                else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
#endif
                SelectionManager.instance.Remove(bricks);
                else
                {
                    SelectionManager.instance.Replace(bricks);
                }
            }

            base.OnClick(brick, pointerEventData);
        }
        protected override List <SelectableBrick> GetSelected(SelectableBrick brick)
        {
            List <SelectableBrick> toSelect = new List <SelectableBrick>();

            //get model root
            var modelRoot = GameObject.Find("Model");

            //get list of all selectable bricks
            var bricks = modelRoot.GetComponentsInChildren <SelectableBrick>();

            //iterate over all bricks
            foreach (var b in bricks)
            {
                //skip groups
                if (b is AgaQTemporaryGroup)
                {
                    continue;
                }

                if (b.uuid == brick.uuid)
                {
                    toSelect.Add(b);
                }
            }

            return(toSelect);
        }
Exemple #4
0
        /// <summary>
        /// Group given bricks
        /// </summary>
        /// <returns>The group.</returns>
        /// <param name="bricsToGroup">Brics to group.</param>
        public SelectableBrick Group(List <SelectableBrick> bricsToGroup)
        {
            bool allOrdinary = true;

            foreach (var brick in bricsToGroup)
            {
                if (!(brick is OrdinaryBrick))
                {
                    allOrdinary = false;
                    break;
                }
            }

            //create group object and prepare it
            SelectableBrick groupScript = allOrdinary ?
                                          (SelectableBrick)BrickBuilder.InstansiateBricksGroup() :
                                          (SelectableBrick)BrickBuilder.InstansiateAgaQGroup();

            //set group center
            groupScript.gameObject.transform.position = bricsToGroup[0].gameObject.transform.position;

            //move selected brck to group
            //and disable brick scripts
            foreach (var brick in bricsToGroup)
            {
                brick.transform.SetParent(groupScript.gameObject.transform);
                brick.grouped = true;
            }

            return(groupScript);
        }
Exemple #5
0
        /// <summary>
        /// Ungroup group.
        /// </summary>
        /// <returns>The ungroup.</returns>
        /// <param name="group">Group.</param>
        public void Ungroup(SelectableBrick group)
        {
            if (!(group is AgaQGroup) && !(group is BricksGroup))
            {
                return;
            }

            //move all brick from group outside,
            //add it to selection and enalble bricks scripts
            for (var i = group.transform.childCount - 1; i >= 0; i--)
            {
                var child = group.transform.GetChild(i);

                child.SetParent(group.transform.parent);

                //enable brick script
                var brickScript = child.GetComponent <Brick>();
                if (brickScript != null)
                {
                    brickScript.grouped = false;
                }

                //add birkc to selection if it is selectable
                var selectable = child.GetComponent <SelectableBrick>();
                if (selectable != null)
                {
                    SelectionManager.instance.Add(selectable);
                }
            }

            //remove group object
            Object.Destroy(group.gameObject);
        }
Exemple #6
0
 public override void OnPointerDown(SelectableBrick brick, PointerEventData pointerEventData)
 {
     if (pointerEventData.button == PointerEventData.InputButton.Left)
     {
         coloringOn = true;
         historyNodes.Add(new HistoryNodeChangeColor(brick.gameObject));
         brick.color = ToolsManager.instance.colorButton.selectedColor;
     }
 }
Exemple #7
0
        public void BeforeEveryTest()
        {
            GameObject gameObject = new GameObject();

            selectionManager = gameObject.AddComponent <SelectionManager>();
            selectionManager.Init();

            gameObject      = new GameObject();
            selectableBrick = gameObject.AddComponent <SelectableBrickMock>();
        }
Exemple #8
0
        public override void OnPointerUp(SelectableBrick brick, PointerEventData pointerEventData)
        {
            if (pointerEventData.button == PointerEventData.InputButton.Left)
            {
                coloringOn = false;

                if (historyNodes.Count > 0)
                {
                    HistoryManager.instance.Register(historyNodes.ToArray());
                    historyNodes.Clear();
                }
            }
        }
Exemple #9
0
 public override void OnClick(SelectableBrick brick, PointerEventData pointerEventData)
 {
     if (!isDragging)
     {
         if (SelectionManager.instance.IsSelected(brick))
         {
             //clone selection
             CloneSelection(brick as DragableBrick, pointerEventData);
         }
         else if (brick is DragableBrick)
         {
             //clone single brick
             Clone(brick as DragableBrick, pointerEventData);
         }
     }
 }
        /// <summary>
        /// Show properties in inspector for given brick.
        /// </summary>
        /// <param name="brick">Brick.</param>
        /// <param name="showDimensions">If set to <c>true</c> show dimensions.</param>
        void ShowProperties(SelectableBrick brick, bool showDimensions)
        {
            colorProperty.SetActive(true);
            colorProperty.SetColor(brick.color);

            if (brick is AgaQBrick)
            {
                scaleProperty.SetActive(true);
                scaleProperty.scaleSelector.SetScale(brick.scale);
            }
            else
            {
                scaleProperty.SetActive(false);
            }

            if (showDimensions && brick is AgaQBrick)
            {
                dimensionsProperties.PrepareProperties(brick as AgaQBrick);
            }
            else
            {
                dimensionsProperties.Clear();
            }
        }
Exemple #11
0
 public virtual void OnPointerUp(SelectableBrick brick, UnityEngine.EventSystems.PointerEventData pointerEventData)
 {
 }
Exemple #12
0
 /// <summary>
 /// Returns list of selected brics based on first one.
 /// </summary>
 /// <returns>The selected bricks</returns>
 /// <param name="brick">Brick.</param>
 protected virtual List <SelectableBrick> GetSelected(SelectableBrick brick)
 {
     return(new List <SelectableBrick> {
         brick
     });
 }