Пример #1
0
 private void Update()
 {
     _rect.anchoredPosition = Input.mousePosition;
     if (Input.GetMouseButtonUp(0))
     {
         if (GameCursor.DropArea != null && GameCursor.CodeBlocks != null && GameCursor.CodeBlocks.Length > 0)
         {
             GameCursor.DropArea.OnBlockDropped();
             GameCursor.CodeBlocks = null;
         }
         else
         {
             GameCursor.ClearBlocks();
         }
     }
 }
Пример #2
0
    private UICodeBlock CreateCodeBlockUI(CodeBlock block)
    {
        var ui = Instantiate(UIResources.CodeBlockPrefab, this.transform);

        ui.CodeBlock = block;
        ui.SetDropAreasActive(false);
        ui.ClickedLeft.AddListener(() =>
        {
            var instance       = Instantiate(ui);
            instance.CodeBlock = GetBlockInstance(block);
            instance.SetDropAreasActive(instance.CodeBlock.CanMove);
            if (GameCursor.CodeBlocks != null && GameCursor.CodeBlocks.Length > 0)
            {
                GameCursor.ClearBlocks();
            }
            else
            {
                GameCursor.CodeBlocks = new UICodeBlock[] { instance }
            };
        });
        return(ui);
    }