void InitializeSerializedProperties() { m_OnBeforePageShown = serializedObject.FindProperty(k_OnBeforeShownEventPropertyPath); /* [NOTE] this would force the callbacks to be "editor + runtime" every time the tutorial page is selected * (but not when the callback is added for the first time), * but this might go against the will of the user */ //ForceCallbacksListenerState(m_OnBeforePageShown, UnityEngine.Events.UnityEventCallState.EditorAndRuntime); m_OnAfterPageShown = serializedObject.FindProperty(k_OnAfterShownEventPropertyPath); m_OnBeforeTutorialQuit = serializedObject.FindProperty(k_OnBeforeTutorialQuitEventPropertyPath); m_OnTutorialPageStay = serializedObject.FindProperty(k_OnTutorialPageStayEventPropertyPath); SerializedProperty paragraphs = serializedObject.FindProperty(k_ParagraphPropertyPath); if (paragraphs == null) { m_WarningMessage = string.Format( Tr("Unable to locate property path {0} on this object. Automatic masking updates will not work."), k_ParagraphPropertyPath ); } else if (paragraphs.arraySize > 0) { SerializedProperty firstParagraph = paragraphs.GetArrayElementAtIndex(0); m_MaskingSettings = firstParagraph.FindPropertyRelative(k_ParagraphMaskingSettingsRelativeProperty); if (m_MaskingSettings == null) { m_WarningMessage = string.Format( Tr("Unable to locate property path {0}.Array.data[0].{1} on this object. Automatic masking updates will not work."), k_ParagraphPropertyPath, k_ParagraphMaskingSettingsRelativeProperty ); } m_Type = firstParagraph.FindPropertyRelative(k_ParagraphTypeProperty); m_HeaderMediaType = (HeaderMediaType)m_Type.intValue; var headerMediaParagraphType = (ParagraphType)m_Type.intValue; // Only Image and Video are allowed for the first paragraph which is always the header media in the new fixed tutorial page layout. if (headerMediaParagraphType != ParagraphType.Image && headerMediaParagraphType != ParagraphType.Video) { m_Type.intValue = (int)ParagraphType.Image; } m_Video = firstParagraph.FindPropertyRelative(k_ParagraphVideoRelativeProperty); m_Image = firstParagraph.FindPropertyRelative(k_ParagraphImageRelativeProperty); switch (paragraphs.arraySize) { case 2: SetupNarrativeOnlyPage(paragraphs); break; case 4: SetupSwitchTutorialPage(paragraphs); break; case 3: default: SetupNarrativeAndInstructivePage(paragraphs); break; } } }
void DrawSimplifiedInspector() { EditorGUILayout.BeginVertical(); if (m_Type != null) { EditorGUILayout.LabelField(Localization.Tr("Header Media Type")); m_HeaderMediaType = (HeaderMediaType)EditorGUILayout.EnumPopup(GUIContent.none, m_HeaderMediaType); m_Type.intValue = (int)m_HeaderMediaType; EditorGUILayout.Space(10); } RenderProperty(Localization.Tr("Media"), m_HeaderMediaType == HeaderMediaType.Image ? m_Image : m_Video); EditorGUILayout.Space(10); RenderProperty(Localization.Tr("Narrative Title"), m_NarrativeTitle); EditorGUILayout.Space(10); RenderProperty(Localization.Tr("Narrative Description"), m_NarrativeDescription); EditorGUILayout.Space(10); RenderProperty(Localization.Tr("Instruction Title"), m_InstructionTitle); EditorGUILayout.Space(10); RenderProperty(Localization.Tr("Instruction Description"), m_InstructionDescription); if (m_CriteriaCompletion != null) { EditorGUILayout.Space(10); EditorGUILayout.LabelField(Localization.Tr("Completion Criteria")); EditorGUILayout.PropertyField(m_CriteriaCompletion, GUIContent.none); EditorGUILayout.PropertyField(m_Criteria, GUIContent.none); } if (m_NextTutorial != null) { EditorGUILayout.Space(10); RenderProperty(Localization.Tr("Next Tutorial"), m_NextTutorial); RenderProperty(Localization.Tr("Next Tutorial button text"), m_TutorialButtonText); } EditorStyles.label.wordWrap = true; //DrawLabelWithImage(Localization.Tr("Custom Callbacks"); EditorGUILayout.BeginHorizontal(); s_ShowEvents = EditorGUILayout.Foldout(s_ShowEvents, s_EventsSectionTitle); if (k_IsAuthoringMode && GUILayout.Button(Localization.Tr("Create Callback Handler"))) { CreateCallbackHandlerScript("TutorialCallbacks.cs"); InitializeEventWithDefaultData(m_OnBeforePageShown); InitializeEventWithDefaultData(m_OnAfterPageShown); GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(10); if (s_ShowEvents) { if (TutorialEditorUtils.EventIsNotInState(m_OnBeforePageShown, UnityEngine.Events.UnityEventCallState.EditorAndRuntime)) { TutorialEditorUtils.RenderEventStateWarning(); EditorGUILayout.Space(8); } RenderEventProperty(s_OnBeforeEventsTitle, m_OnBeforePageShown); EditorGUILayout.Space(5); if (TutorialEditorUtils.EventIsNotInState(m_OnAfterPageShown, UnityEngine.Events.UnityEventCallState.EditorAndRuntime)) { TutorialEditorUtils.RenderEventStateWarning(); EditorGUILayout.Space(8); } RenderEventProperty(s_OnAfterEventsTitle, m_OnAfterPageShown); EditorGUILayout.Space(10); } RenderProperty(Localization.Tr("Enable Masking"), m_MaskingSettings); EditorGUILayout.EndVertical(); DrawPropertiesExcluding(serializedObject, k_PropertiesToHide); serializedObject.ApplyModifiedProperties(); }