コード例 #1
0
    public void UndoAction()
    {
        foreach (GameObject obj in instanciatedObjects)
        {
            if (obj == null)
            {
                instanciatedObjects.Remove(obj);
            }
        }
        if (instanciatedObjects.Count > 0)
        {
            //GameObject removeObj = new GameObject();

            int index = instanciatedObjects.Count - 1;
            if (instanciatedObjects[index] == null)
            {
                instanciatedObjects.Remove(instanciatedObjects[index]);
                UndoAction();
            }
            var removeObj = instanciatedObjects[index];
            if (removeObj.name.Contains("Chair"))
            {
                total = total - 100;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.name.Contains("Desk"))
            {
                total = total - 200;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.name.Contains("FloorCube1 1"))
            {
                total = total - 100;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            else if (removeObj.name.Contains("FloorCube1"))
            {
                total = total - 25;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }

            if (removeObj.name.Contains("FloorCube4"))
            {
                total = total - 30;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.name.Contains("FloorCube5"))
            {
                total = total - 32;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.name.Contains("z9e_prefab"))
            {
                total = total - 250;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.name.Contains("Door1"))
            {
                total = total - 250;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.name.Contains("GlassDoor"))
            {
                total = total - 1000;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.name.Contains("LongGlass"))
            {
                total = total - 2500;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.name.Contains("WallCorner"))
            {
                total = total - 250;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.name.Contains("WallCorner2"))
            {
                total = total - 250;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.name.Contains("WindowWall"))
            {
                total = total - 250;
                costText.GetComponentInChildren <Text>().text = prefix + total.ToString();
            }
            if (removeObj.tag.Contains("Door") || removeObj.tag.Contains("Window"))
            {
                removeObj.GetComponent <DetectCollison>().OnUndo();
            }
            if (removeObj)
            {
                Destroy(removeObj);
            }
            instanciatedObjects.RemoveAt(instanciatedObjects.Count - 1);
            if (scrollList != null)
            {
                scrollList.RemoveLastItem();
            }
            CamAdjust = true;
        }
    }