public override void OnInspectorGUI() { m_editorUtils.Initialize(); // Do not remove this! m_spawnerSettings = (SpawnerSettings)target; string message = m_editorUtils.GetTextValue("Intro");; EditorGUILayout.HelpBox(message, MessageType.Info, true); if (GUILayout.Button(m_editorUtils.GetContent("AddToScene"))) { m_spawnerSettings.CreateSpawner(); } GUILayout.Label(m_editorUtils.GetContent("SpawnRulePreview"), m_editorUtils.Styles.heading); GaiaResource resource = m_spawnerSettings.m_resources;// (GaiaResource)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_spawnerSettings.m_resourcesGUID), typeof(GaiaResource)); foreach (SpawnRule rule in m_spawnerSettings.m_spawnerRules) { m_editorUtils.LabelField("Name", new GUIContent(rule.m_name)); m_editorUtils.LabelField("Type", new GUIContent(rule.m_resourceType.ToString())); Texture2D resourceTexture = SpawnerEditor.GetSpawnRulePreviewTexture(rule, resource); if (resourceTexture != null) { m_editorUtils.Image(resourceTexture, 100, 100); } } }
private void SelectStampPanel(bool helpEnabled) { m_editorUtils.InlineHelp("Help", helpEnabled); if (m_editedImageMask == null && m_editedStamperSettings == null) { EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("NoConnectedImageMask"), MessageType.Warning, true); } m_editorUtils.Label("StampPreview"); EditorGUILayout.BeginVertical(); if (m_previewTexture != null && m_validStampInCategory) { m_editorUtils.Image(m_previewTexture, position.width - 25, position.width - 25); m_editorUtils.Label(new GUIContent(m_previewTexture.name)); } else { if (!m_validStampInCategory) { GUILayout.Space(71); EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("NoValidStampInCategory"), MessageType.Info, true); } else if (m_previewTexture == null) { GUILayout.Space(67); EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("NoTexture"), MessageType.Info, true); } GUILayout.Space(155); } GUILayout.Space(EditorGUIUtility.singleLineHeight); Rect rect = EditorGUILayout.GetControlRect(); if (GUI.Button(new Rect(rect.x, rect.y, 50, EditorGUIUtility.singleLineHeight), m_editorUtils.GetContent("StampBackwardButton"))) { PickNextStamp(-1); } //Building up a value array of incrementing ints of the size of the directory names array, this array will then match the displayed string selection in the popup int[] categoryIDArray = Enumerable .Repeat(0, (int)((m_categoryNames.ToArray().Length - 0) / 1) + 1) .Select((tr, ti) => tr + (1 * ti)) .ToArray(); int previousCategoryID = m_selectedCategoryID; m_selectedCategoryID = EditorGUI.IntPopup(new Rect(rect.x + 60, rect.y, rect.width - 120, EditorGUIUtility.singleLineHeight), m_selectedCategoryID, m_categoryNames.ToArray(), categoryIDArray); if (previousCategoryID != m_selectedCategoryID) { LoadStampDirFileInfo(); m_currentStampIndex = -1; m_validStampInCategory = PickNextStamp(1); } if (GUI.Button(new Rect(rect.x + 60 + rect.width - 110, rect.y, 50, EditorGUIUtility.singleLineHeight), m_editorUtils.GetContent("StampForwardButton"))) { PickNextStamp(1); } rect.y += EditorGUIUtility.singleLineHeight * 2; if (GUI.Button(new Rect(rect.x + 20, rect.y, 100, EditorGUIUtility.singleLineHeight * 2), m_editorUtils.GetContent("ApplyButton"))) { Close(); } if (GUI.Button(new Rect(rect.x + rect.width - 100 - 20, rect.y, 100, EditorGUIUtility.singleLineHeight * 2), m_editorUtils.GetContent("CancelButton"))) { //Load original stamp back in and close if (m_editedImageMask != null) { m_editedImageMask.ImageMaskTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_originalTextureGUID), typeof(Texture2D)); } //if (m_editedStamperSettings != null) //{ // m_editedStamperSettings.m_stamperInputImage = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_originalTextureGUID), typeof(Texture2D)); //} UpdateToolsAndScene(); Close(); } EditorGUILayout.EndVertical(); }