public FreeFormPanel() { this.SnapsToDevicePixels = true; this.AllowDrop = true; connectorEditor = null; lastYPosition = FreeFormPanel.TopStackingMargin; }
public static void AddSwitchToGameElement(Switch swt, GameElement gameElement) { SpriteRenderer spriteRenderer = gameElement.GetComponent<SpriteRenderer>(); if (spriteRenderer != null) { spriteRenderer.enabled = false; } bool alreadyAdded = false; foreach (GameElement ge in gameElement.GameElements) { if (ge == swt) { alreadyAdded = true; break; } } if (alreadyAdded) { return; } SerializedObject serializedObject = new SerializedObject(gameElement); SerializedProperty geProperty = serializedObject.FindProperty("gameElements"); geProperty.InsertArrayElementAtIndex(geProperty.arraySize); SerializedProperty element = geProperty.GetArrayElementAtIndex(geProperty.arraySize - 1); element.objectReferenceValue = swt; serializedObject.ApplyModifiedProperties(); Editor connectorEditor = ConnectorEditor.CreateEditor(gameElement); connectorEditor.OnInspectorGUI(); }
void CreateNewConnectorEditor(MouseButtonEventArgs e) { if (connectorEditor == null || !e.Source.Equals(connectorEditor.Connector)) { //If user clicks anywhere other than the connector editor, destroy it. RemoveConnectorEditor(); if (e.Source.GetType().IsAssignableFrom(typeof(Connector))) { this.connectorEditor = new ConnectorEditor(this, e.Source as Connector); } } }
protected override void OnKeyDown(KeyEventArgs e) { if (e != null && !this.Disabled && this.IsOutmostPanel()) { if (e.Key == Key.Escape) { //If escape key is hit while dragging a connector, end dragging. if (connectorEditor != null && connectorEditor.BeingEdited) { Connector affectedConnector = connectorEditor.Connector; RemoveConnectorEditor(); this.connectorEditor = new ConnectorEditor(this, affectedConnector); e.Handled = true; } } } base.OnKeyDown(e); }
public void RemoveConnectorEditor() { if (connectorEditor != null) { connectorEditor.Remove(); connectorEditor = null; } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); bool isUpdateElementCollidersButtonClicked = GUILayout.Button("Update Element Colliders"); if (isUpdateElementCollidersButtonClicked) { ElementCollider[] elementColliders = this.target.GetComponentsInChildren <ElementCollider>(true); foreach (ElementCollider elementCollider in elementColliders) { ElementColliderEditor.UpdateColliders(elementCollider, target.StageNum == 38 ? 0.033f : 0.055f); } } bool isUpdatePullersButtonClicked = GUILayout.Button("Update Pullers/End Pullers"); if (isUpdatePullersButtonClicked) { Puller[] pullers = this.target.GetComponentsInChildren <Puller>(true); foreach (Puller puller in pullers) { PullerEditor.UpdatePullers(puller); } } bool isApplyMasksButtonClicked = GUILayout.Button("Apply Masks"); if (isApplyMasksButtonClicked) { Puller[] pullers = this.target.GetComponentsInChildren <Puller>(true); foreach (Puller puller in pullers) { PullerEditor.ApplyMask(puller); } } bool isSetPullersButtonClicked = GUILayout.Button("Set Pullers"); if (isSetPullersButtonClicked) { Switch[] switches = this.target.GetComponentsInChildren <Switch>(true); for (int i = 0; i < 10; i++) { foreach (Switch swt in switches) { swt.LookForPullers(); } } GameElement[] gameElements = this.target.GetComponentsInChildren <GameElement>(true); foreach (GameElement gameElement in gameElements) { if (!(gameElement is Switch)) { gameElement.SetPullers(); } } } bool isAutoLinkButtonClicked = GUILayout.Button("Link Switches"); if (isAutoLinkButtonClicked) { Switch[] switches = this.target.GetComponentsInChildren <Switch>(true); foreach (Switch swt in switches) { SwitchEditor.LinkElements(swt); } } bool isDoubleLinkButtonClicked = GUILayout.Button("Double Link Connectors"); if (isDoubleLinkButtonClicked) { Connector[] connectors = this.target.GetComponentsInChildren <Connector>(true); foreach (Connector connector in connectors) { foreach (GameElement ge in connector.GameElements) { if (!(ge is Connector)) { continue; } bool alreadyAdded = false; foreach (GameElement gameElement in ge.GameElements) { if (gameElement != connector) { continue; } alreadyAdded = true; break; } if (alreadyAdded) { continue; } SerializedObject serializedObject = new SerializedObject(ge); SerializedProperty geProperty = serializedObject.FindProperty("gameElements"); geProperty.InsertArrayElementAtIndex(geProperty.arraySize); SerializedProperty element = geProperty.GetArrayElementAtIndex(geProperty.arraySize - 1); element.objectReferenceValue = connector; serializedObject.ApplyModifiedProperties(); Editor connectorEditor = ConnectorEditor.CreateEditor(ge); connectorEditor.OnInspectorGUI(); } } } }