private void SelectPlatformCallback(object data) { if (this.trigger.igniters.ContainsKey((int)data)) { return; } int index = this.spIgnitersKeys.arraySize; this.spIgnitersKeys.InsertArrayElementAtIndex(index); this.spIgnitersValues.InsertArrayElementAtIndex(index); this.spIgnitersKeys.GetArrayElementAtIndex(index).intValue = (int)data; Igniter igniter = this.trigger.gameObject.AddComponent <IgniterTriggerEnter>(); igniter.Setup(this.trigger); igniter.enabled = false; this.spIgnitersValues.GetArrayElementAtIndex(index).objectReferenceValue = igniter; this.ignitersIndex = index; EditorPrefs.SetInt(KEY_IGNITER_INDEX_PREF, this.ignitersIndex); this.serializedObject.ApplyModifiedProperties(); this.serializedObject.Update(); this.updateIgnitersPlatforms = true; }
private void SelectNewIgniter(Type igniterType) { SerializedProperty property = this.spIgnitersValues.GetArrayElementAtIndex(this.ignitersIndex); if (property.objectReferenceValue != null) { DestroyImmediate(property.objectReferenceValue, true); property.objectReferenceValue = null; } Igniter igniter = (Igniter)this.trigger.gameObject.AddComponent(igniterType); igniter.Setup(this.trigger); igniter.enabled = false; property.objectReferenceValue = igniter; this.ignitersCache[this.ignitersIndex] = new IgniterCache(igniter); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); }
// INITIALIZERS: ----------------------------------------------------------------------------------------------- private void OnEnable() { if (serializedObject == null) { return; } this.trigger = (NetworkItem)target; this.tabIndex = this.prevTabIndex = EditorPrefs.GetInt(string.Format(KEY_STATE, target.GetHashCode())); this.sectionTrigger = new Section( "Pickup Trigger", "Trigger icon.png", this.Repaint, "Assets/Gizmos/GameCreator/Core"); //this.sectionParameters = new EditorGUIUtils.Section("Parameters", "List.png", this.Repaint); this.sectionStartActions = new Section( "On Start", "On Start.png", this.Repaint, "Assets/Plugins/GameCreator/Extra/Icons/Igniters"); this.sectionEvent = new Section( "On Picked Up", "Pickup.png", this.Repaint); this.spRespawn = serializedObject.FindProperty("secondsBeforeRespawn"); /*if(trigger.actions.Count == 0) * { * trigger.actions.Add(new Actions() { actionsList = trigger.onPickUpActions }); * }*/ SerializedProperty spIgniters = serializedObject.FindProperty("igniters"); this.spIgnitersKeys = spIgniters.FindPropertyRelative("keys"); this.spIgnitersValues = spIgniters.FindPropertyRelative("values"); if (this.spIgnitersKeys.arraySize == 0) { Igniter igniter = this.trigger.gameObject.AddComponent <IgniterTriggerEnter>(); igniter.Setup(this.trigger); igniter.enabled = false; this.spIgnitersKeys.InsertArrayElementAtIndex(0); this.spIgnitersValues.InsertArrayElementAtIndex(0); this.spIgnitersKeys.GetArrayElementAtIndex(0).intValue = Trigger.ALL_PLATFORMS_KEY; this.spIgnitersValues.GetArrayElementAtIndex(0).objectReferenceValue = igniter; this.serializedObject.ApplyModifiedProperties(); this.serializedObject.Update(); } this.UpdateIgnitersPlatforms(); this.ignitersIndex = EditorPrefs.GetInt(KEY_IGNITER_INDEX_PREF, 0); if (this.ignitersIndex >= this.spIgnitersKeys.arraySize) { this.ignitersIndex = this.spIgnitersKeys.arraySize - 1; EditorPrefs.SetInt(KEY_IGNITER_INDEX_PREF, this.ignitersIndex); } this.spMinDistance = serializedObject.FindProperty("minDistance"); this.spMinDistanceToPlayer = serializedObject.FindProperty("minDistanceToPlayer"); }