public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { StoriesCreator storiesCreator = fieldInfo.GetValue(property.serializedObject.targetObject) as StoriesCreator; if (storiesCreator.entryStory != null) { return(EditorGUI.GetPropertyHeight(property)); } return(EditorGUI.GetPropertyHeight(property) + BUTTON_HEIGHT + PADDING + PADDING); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { StoriesCreator storiesCreator = fieldInfo.GetValue(property.serializedObject.targetObject) as StoriesCreator; // Add generate entry story button var buttonPos = new Rect(new Vector2(position.x, position.y + EditorGUI.GetPropertyHeight(property) + PADDING), new Vector2(position.width, BUTTON_HEIGHT)); if (storiesCreator.entryStory == null && GUI.Button(buttonPos, "Create Entry Story")) { var entryStory = ScriptableObject.CreateInstance <EntryStory>(); AssetDatabase.CreateAsset(entryStory, StoriesUtils.GetSelectedPathOrFallback() + "/EntryStory.asset"); AssetDatabase.SaveAssets(); storiesCreator.entryStory = entryStory; } // Draw default EditorGUI.PropertyField(position, property, label, true); }
public void TestDispatch() { var store = ScriptableObject.CreateInstance("Stories") as Stories; var storiesCreator = new StoriesCreator(); var entryStory = ScriptableObject.CreateInstance("EntryStory") as EntryStory; var testStory = ScriptableObject.CreateInstance("TestStory") as TestStory; entryStory.subStories = new Story[1] { testStory }; storiesCreator.entryStory = entryStory; store.storiesCreator = storiesCreator; store.CreateStories(); var actionListenerWasCalled = false; store.Listen((StoryAction storyAction) => { actionListenerWasCalled = true; }); store.Dispatch(new TestStory.TestAction()); Assert.That(actionListenerWasCalled, Is.True); Assert.That(testStory.updated, Is.True); }