Exemplo n.º 1
0
        private void OnLayerCreate(Layer layer)
        {
            var go     = GameObject.Instantiate(layerData.layerPrefab, layerData.layersParent);
            var toggle = go.GetComponent <Toggle> ();

            toggle.group = layerData.layersToggleGroup;

            go.GetComponent <MouseClickEventSender> ().OnRightClicked.AddListener(() =>
            {
                var menu = new ContextMenuPresenter(contextMenuData, Input.mousePosition);
                menu.AddMenuItem("Delete", () => stack.DeleteLayer(layer));
                menu.AddMenuItem("Reset", () => layer.Reset());
                menu.AddMenuItem("Add Affector", () => AddAffector(layer));
            });

            var deleteButton = go.GetComponentsInChildren <Button> ().Where(b => b.gameObject.name == "Delete").First();

            deleteButton.onClick.AddListener(() => stack.DeleteLayer(layer));

            layerGOs.Add(layer.ID, toggle);
            SetActiveLayer(layer);
        }