public static void BuildBlock(BlockModel.Block _block, GameObject _obj, CustomElementModel.CustomElementStatus _elementStatus) { Transform tsExpression = _obj.transform.Find("expression"); Color color = FacadeUtility.HexToColor(_block.color); GameObject expressionClone = null; int line = _block.elements.Count; expressionClone = cloneExpression(tsExpression.gameObject, color, line > 1 ? imgBlockHead : imgBlockSingle, line == 1 ? Symbol.Single : Symbol.Left); decorateElements(expressionClone, _block.elements[0], new Dictionary <string, string>(), _elementStatus); for (int i = 1; i < _block.elements.Count; ++i) { Symbol symbol = Symbol.Blank; Sprite sprite = imgBlockBlank; // blank cloneExpression(tsExpression.gameObject, color, sprite, symbol); if (i == line - 1) { // last one symbol = Symbol.Right; sprite = imgBlockFoot; } else { symbol = Symbol.Middle; sprite = imgBlockMiddle; } expressionClone = cloneExpression(tsExpression.gameObject, color, sprite, symbol); decorateElements(expressionClone, _block.elements[i], new Dictionary <string, string>(), _elementStatus); } Transform tsDrag = _obj.transform.Find("#drag"); tsDrag.SetAsLastSibling(); DragBlock drag = tsDrag.GetComponent <DragBlock>(); drag.method = _block.method; }
public void OnDrop(PointerEventData eventData) { GameObject go = eventData.pointerDrag; if (null == go) { return; } DragBlock block = go.GetComponent <DragBlock>(); if (null == block) { return; } Debug.Log(block.method); if (null != onBlockDrop) { onBlockDrop(block); } }
private void onBlockDrop(DragBlock _block) { model.UpdateNewUnit(_block.method, 0); }