protected override void OnScrollableGUI(ref VerticalGUIRect rect, int index) { ItemData item = MainWnd.Items[index]; rect.Space(10); using (new EditorGUI.DisabledGroupScope(true)) { EditorGUI.IntField(rect.Next, s_IDContent, item.ID); } item.InternalName = EditorGUI.TextField(rect.Next, s_InternalNameContent, item.InternalName); item.Icon = EditorAssetUtility.AssetPtrField(rect.Next, s_IconContent, item.Icon, typeof(Sprite)); item.Block = EditorGUI.TextField(rect.Next, s_BlockContent, item.Block); item.Attack = EditorGUI.IntField(rect.Next, s_AttackContent, item.Attack); item.Rarity = EditorGUI.IntSlider(rect.Next, s_RarityContent, item.Rarity, 1, 6); item.MaxStackCount = EditorGUI.IntSlider(rect.Next, s_MaxStackCountContent, item.MaxStackCount, 1, 99); rect.Space(10); EditorGUI.LabelField(rect.Next, s_DescriptionContent, EditorStyles.boldLabel); item.Description = EditorGUI.TextArea(rect.GetNext(s_TextAreaHeight, true, true), item.Description); rect.Space(10); EditorGUI.LabelField(rect.Next, s_UsageContent, EditorStyles.boldLabel); item.Usage = EditorGUI.TextArea(rect.GetNext(s_TextAreaHeight, true, true), item.Usage); rect.Space(10); EditorGUI.LabelField(rect.Next, s_ObtainApproachContent, EditorStyles.boldLabel); item.ObtainApproach = EditorGUI.TextArea(rect.GetNext(s_TextAreaHeight, true, true), item.ObtainApproach); rect.Space(10); }
private void AudioFieldsGUI(ref VerticalGUIRect guiRect, BlockData block) { block.DigAudio = EditorAssetUtility.AssetPtrField(guiRect.Next, s_DigAudioContent, block.DigAudio, typeof(AudioClip)); block.PlaceAudio = EditorAssetUtility.AssetPtrField(guiRect.Next, s_PlaceAudioContent, block.PlaceAudio, typeof(AudioClip)); guiRect.Space(10); m_StepAudioList ??= new ReorderableList(null, typeof(AssetPtr), true, true, true, true) { elementHeight = EditorGUIUtility.standardVerticalSpacing + EditorGUIUtility.singleLineHeight, drawHeaderCallback = (Rect pos) => { EditorGUI.LabelField(pos, s_StepAudiosContent); }, drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { rect.y += EditorGUIUtility.standardVerticalSpacing; rect.height = EditorGUIUtility.singleLineHeight; AssetPtr asset = m_StepAudioList.list[index] as AssetPtr; m_StepAudioList.list[index] = EditorAssetUtility.AssetPtrField(rect, GUIContent.none, asset, typeof(AudioClip)); } }; m_StepAudioList.list = block.StepAudios ??= new List <AssetPtr>(); m_StepAudioList.DoList(guiRect.GetNext(m_StepAudioList.GetHeight(), true, true)); }
public void ElementGUI(Rect rect, GUIContent label, ref int?location) { AssetPtr asset = location == null ? AssetPtr.NullPtr : Elements[location.Value].Asset; AssetPtr newAsset = EditorAssetUtility.AssetPtrField(rect, label, asset, typeof(T), out bool changed); if (changed) { SetAssetToLocation(ref location, newAsset); } }
private void RenderingFieldsGUI(ref VerticalGUIRect guiRect, BlockData block) { MainWnd.BlockMeshes.ElementGUI(guiRect.Next, s_MeshContent, ref block.Mesh); AssetPtr meshPtr = MainWnd.BlockMeshes[block.Mesh]; BlockMesh mesh = EditorAssetUtility.LoadAssetByGUID <BlockMesh>(meshPtr.AssetGUID); if (!mesh) { EditorGUI.HelpBox(guiRect.GetNext(40, true, true), "You should assign an empty mesh if you do not want this block to be rendered.", MessageType.Error); } else if (mesh.Faces.Length == 0) { EditorGUI.HelpBox(guiRect.GetNext(40, true, true), "This block will never be rendered.", MessageType.Warning); } else { MainWnd.BlockMaterials.ElementGUI(guiRect.Next, s_MaterialContent, ref block.Material); BlockMesh.FaceData[] faces = mesh.Faces; ArrayUtility.EnsureArrayReferenceAndSize(ref block.Textures, faces.Length, true); for (int i = 0; i < faces.Length; i++) { BlockFace face = faces[i].Face; EditorGUI.LabelField(guiRect.Next, face.ToString(), EditorStyles.boldLabel); ArrayUtility.EnsureArrayReferenceAndSize(ref block.Textures[i], 3, true); EditorGUI.indentLevel++; for (int j = 0; j < 3; j++) { MainWnd.BlockTextures.ElementGUI(guiRect.Next, s_TextureContents[j], ref block.Textures[i][j]); } EditorGUI.indentLevel--; } } }