コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }