예제 #1
0
        /// <summary>
        /// Instansiate new brick in place of all one.
        /// Copy to new brick position, rotation and scale.
        /// Make old brick inactive.
        /// </summary>
        /// <returns>The new brick.</returns>
        /// <param name="newBrickPath">New brick resources path.</param>
        /// <param name="oldBrick">Old brick.</param>
        Brick ChangeBrick(string newBrickPath, AgaQBrick oldBrick)
        {
            var newBrick = BrickBuilder.InstansiateFromResources(newBrickPath);

            if (newBrick == null)
            {
                return(null);
            }

            newBrick.transform.position   = oldBrick.transform.position;
            newBrick.transform.rotation   = oldBrick.transform.rotation;
            newBrick.transform.localScale = oldBrick.transform.localScale;

            if (oldBrick.isDragging && ToolsManager.instance.tool is MoveTool)
            {
                //let exchange bricks in move tool
                (ToolsManager.instance.tool as MoveTool).ChangeBrick(newBrick as DragableBrick);
            }
            else
            {
                oldBrick.gameObject.SetActive(false);
            }

            return(newBrick);
        }
예제 #2
0
        /// <summary>
        /// Add new brick to scene.
        /// </summary>
        /// <param name="resourcePath">Resource path.</param>
        /// <param name="presentFirst">If true present first brick at center of edit area and wait for cursor entering edit area.</param>
        public void Add(string resourcePath, bool presentFirst)
        {
            if (dragableBrick != null)
            {
                OnCancel();
            }

            var newBrick = BrickBuilder.InstansiateFromResources(resourcePath);

            if (newBrick != null)
            {
                Add(newBrick, presentFirst);
            }
        }