예제 #1
0
    public void GeneratorDragEndOnBoard(string prefabPath)
    {
        var board         = boards [currentBoard];
        var prefabToClone = (Resources.Load(prefabPath) as GameObject).GetComponent <Element> ();

        if (prefabToClone == null)
        {
            throw new MissingComponentException("Prefab should have Element component");
        }
        Destroy(generatorDragMarker);
        var prefab = Instantiate(prefabToClone);

        prefab.transform.parent     = board.transform;
        prefab.transform.localScale = new Vector3(100, 100, 100);
        var localPoint = new Vector2();

        if (RectTransformUtility.ScreenPointToLocalPointInRectangle(board.rect, new Vector2(Input.mousePosition.x, Input.mousePosition.y), Camera.main, out localPoint))
        {
            prefab.transform.localPosition = new Vector3(localPoint.x, localPoint.y, -10);
        }
        else
        {
            throw new UnityException("Shouldn't happen. If it does I have no idea why");
        }

        generatorDragMarker = null;
        generatorDragPhase  = GeneratorDragPhase.EndOverBoard;
    }
예제 #2
0
 public void GeneratorBeginDrag(string prefabPath)
 {
     Destroy(generatorDragMarker);
     generatorDragMarker = Instantiate(Resources.Load(prefabPath) as GameObject);
     generatorDragMarker.transform.localScale = new Vector3(1, 1, 1);
     generatorDragMarker.transform.position   = new Vector3(Utilities.mousePositionWorld.x, Utilities.mousePositionWorld.y, -2);
     generatorDragPhase = GeneratorDragPhase.Begin;
 }
예제 #3
0
 public void GeneratorDragCancel()
 {
     Destroy(generatorDragMarker);
     generatorDragMarker = null;
     generatorDragPhase  = GeneratorDragPhase.Cancel;
 }