public void OnDrop(PointerEventData eventData) { if (!HasDraggedObjectAValidTag(eventData)) { return; } var allContainers = GetAllCodeLineContainersSorted(); if (unpinnedCodeline != null) { allContainers.Remove(unpinnedCodeline.container); } CodeLine parentLine = GetParentBlockUnderMousePosition(allContainers); List <GameObject> childInstructions = GetChildListBasedOnRoot(parentLine); int index = GetIndexToInsertUnderMousePosition(childInstructions); if (parentLine != null) { Debug.Log($"parentLine", parentLine.container); } CodeLine lineToInsert = unpinnedCodeline ?? CodeLineFactory.GetStandardCodeLine(eventData.pointerDrag); InsertAtLine(lineToInsert, index, parentLine); HandlePostDrag(lineToInsert, eventData); InsertJumpLabelInstructionIfNeeded(lineToInsert, index, parentLine); ActivateDropdownIfNeeded(lineToInsert, eventData); Pin(); }
// Start is called before the first frame update void Start() { InitializeSolutions(); InitializeGhostInstruction(); draggedObject = null; fakeSingleLine = CodeLineFactory.GetStandardCodeLine(GameObject.Instantiate(GameObject.Find("MoveInstruction"))); fakeSingleLine.container.transform.SetParent(GameObject.Find("NotVisible").transform); //fakeSingleLine.instruction.transform.SetParent(GameObject.Find("NotVisible").transform); ghostInstruction = GameObject.Find("GhostInstruction"); scrollY = 0; }
private void InsertJumpLabelInstructionIfNeeded(CodeLine insertedLine, int index, CodeLine parentLine) { if (unpinnedCodeline != null) { return; } if (!InstructionHelper.IsJumpInstruction(insertedLine.instruction)) { return; } if (InstructionHelper.IsJumpInstructionLabel(insertedLine.instruction)) { return; } var jumpLabel = insertedLine.instruction.GetComponent <JumpInstructionScript>().CreateBindedLabel(); var labelCodeLine = CodeLineFactory.GetStandardCodeLine(jumpLabel); InsertAtLine(labelCodeLine, index, parentLine); insertedLine.instruction.GetComponent <JumpInstructionScript>().AttachArrow(); }