public void OnDrop(PointerEventData eventData) { if (!editor) { if (empty) { if (eventData.pointerDrag != null) { RectTransform other = eventData.pointerDrag.GetComponent <RectTransform>(); if (other != null) { if (other.localScale.x <= place.localScale.x + scaleOffsetX && other.localScale.y <= place.localScale.y + scaleOffsetY && other.localScale.x >= place.localScale.x - scaleOffsetX && other.localScale.y >= place.localScale.y - scaleOffsetY && other.GetComponent <DragDrop>().imageID.Equals(imageID)) { eventData.pointerDrag.GetComponent <RectTransform>().anchoredPosition = GetComponent <RectTransform>().anchoredPosition; other.localScale = place.localScale; other.rotation = place.rotation; LevelManager.Instance.UnselectObject(); DragDrop dg = other.GetComponent <DragDrop>(); dg.DisableMovement(); if (dg.contextID != contextID) { negative = true; } SoundManager.Instance.PlaySound(2); empty = false; } else { //other.GetComponent<DragDrop>().ResetLastPosition(); //LevelManager.Instance.UnselectObject(); SoundManager.Instance.PlaySound(4); } } } } } }
public void CreateObj() { GameObject go = Instantiate(selected, spawnArea.transform); ObjectT OT = go.AddComponent <ObjectT>(); OT.prefabTyp = prefabType; switch (type) { case GenObjectType.Drag: DragDrop dg = go.AddComponent <DragDrop>(); dg.DisableMovement(); OT.SetTyp(GenObjectType.Drag, icons[0]); if (OT.prefabTyp.Equals(PrefabType.Tvar)) { AssignId(dg, OT); dg.type = "Drag"; } if (OT.prefabTyp.Equals(PrefabType.Basic)) { AssignId(dg, OT); dg.type = "Drag"; dg.imageID = 900; } break; case GenObjectType.Click: ClickableObject co = go.AddComponent <ClickableObject>(); OT.SetTyp(GenObjectType.Click, icons[1]); co.imgFace = new List <Texture2D>(basicTextures); co.img.texture = basicTextures[0]; co.type = "Click"; OT.prefabTyp = PrefabType.Swap; co.editor = true; break; case GenObjectType.Static: ItemSlot itemslot = go.AddComponent <ItemSlot>(); OT.SetTyp(GenObjectType.Static, icons[2]); if (prefabType.Equals(PrefabType.Tvar)) { itemslot.img.color = Color.gray; itemslot.img.texture = rectangleText; itemslot.objectName = "Static tvar " + staticContextID; itemslot.type = "Stat"; staticContextID++; } if (prefabType.Equals(PrefabType.Basic)) { } break; case GenObjectType.Afk: OT.SetTyp(GenObjectType.Afk, icons[2]); ItemSlot itemSlot = go.AddComponent <ItemSlot>(); itemSlot.contextID = -999; itemSlot.imageID = -999; itemSlot.objectName = "Statický obj"; itemSlot.type = "Afk"; itemSlot.editor = true; break; } ObjectModificator.Instance.SelectObject(OT.GetComponent <GeneratedObject>(), OT); }