public override void OnInspectorGUI() {
        serializedObject.Update();
        
        var t = target as RepeatedRenderer3D;

        Header();

        Section("Textures", () => {

            FieldTextureMode();

            EditorGUILayout.BeginHorizontal();
            FieldSprite(textureIcon, atlasTextureIconGUID, "Icon");
            //MadGUI.PropertyField(textureIcon, "Icon");
            EditorGUILayout.PropertyField(tintIcon, new GUIContent(""), new GUILayoutOption[] { GUILayout.Width(50) });
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            FieldSprite(textureSlot, atlasTextureSlotGUID, "Slot");
            //MadGUI.PropertyField(textureSlot, "Slot");
            EditorGUILayout.PropertyField(tintSlot, new GUIContent(""), new GUILayoutOption[] { GUILayout.Width(50) });
            EditorGUILayout.EndHorizontal();

            FieldPremultipliedAlpha();

            CheckTextureIsReadable(t.textureIcon);
            CheckTextureIsReadable(t.textureSlot);
        });

        SectionPositionAndSize();

        Section("Appearance", () => {
            MadGUI.PropertyField(repeatCount, "Repeat Count");
            MadGUI.PropertyFieldVector2(repeatPositionDelta, "Icon Distance");
            MadGUI.PropertyField(repeatRotationDelta, "Icon Rotation");

            MadGUI.PropertyField(growType, "Grow Type");
            MadGUI.ConditionallyEnabled(growType.enumValueIndex == (int) RepeatedRenderer3D.GrowType.Fill, () => {
                MadGUI.PropertyField(fillDirection, "Fill Direction");
            });

            FieldLabel();
        });

        Section("Effects", () => {
            FieldSmoothEffect();
        });
        
        EditorGUILayout.Space();
        
        serializedObject.ApplyModifiedProperties();
    }
    private void SectionTextures() {
        Section("Textures", () => {
            MadGUI.PropertyField(renderingMethod, "Render Method");
            FieldTextureMode();

            EditorGUILayout.Space();

            if (script.textureMode != EnergyBar3DBase.TextureMode.TextureAtlas || script.atlas != null) {
                switch (script.renderingMethod) {
                    case SequenceRenderer3D.Method.Grid:
                        FieldSprite(gridTexture, gridAtlasTextureGUID, "Bar Texture");

                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label("Grid Size");
                        GUILayout.FlexibleSpace();
                        MadGUI.LookLikeControls(30, 50);
                        EditorGUILayout.PropertyField(gridWidth, new GUIContent("W"));
                        MadGUI.PropertyField(gridHeight, "H");
                        MadGUI.LookLikeControls(0, 0);
                        EditorGUILayout.EndHorizontal();

                        MadGUI.PropertyField(gridFrameCountManual, "Manual Frame Count");
                        MadGUI.ConditionallyEnabled(gridFrameCountManual.boolValue, () => {
                            MadGUI.PropertyField(gridFrameCount, "Frame Count");
                        });
                        break;

                    case SequenceRenderer3D.Method.Sequence:
                        FieldSequenceTextures();
                        break;
                }

                EditorGUILayout.Space();

                MadGUI.PropertyField(gridTint, "Tint");

                EditorGUILayout.Space();

                FieldBackgroundTextures();
                FieldForegroundTextures();
                FieldPremultipliedAlpha();
            }
        });
    }
    public override void OnInspectorGUI() {
        serializedObject.Update();
        
        var t = target as RepeatedRenderer3D;
        
        if (MadGUI.Foldout("Textures", true)) {
            MadGUI.BeginBox();
            
            EditorGUILayout.BeginHorizontal();
            MadGUI.PropertyField(textureIcon, "Icon");
            EditorGUILayout.PropertyField(tintIcon, new GUIContent(""), new GUILayoutOption[] { GUILayout.Width(50) });
            EditorGUILayout.EndHorizontal();
            
            EditorGUILayout.BeginHorizontal();
            MadGUI.PropertyField(textureSlot, "Slot");
            EditorGUILayout.PropertyField(tintSlot, new GUIContent(""), new GUILayoutOption[] { GUILayout.Width(50) });
            EditorGUILayout.EndHorizontal();
            
            CheckTextureIsReadable(t.textureIcon);
            CheckTextureIsReadable(t.textureSlot);
            
            MadGUI.EndBox();
        }
        
        if (showPositionAndSize && MadGUI.Foldout("Position & Size", true)) {
            MadGUI.BeginBox();
            
            if (MadGUI.Button("Make Pixel-Perfect")) {
                t.transform.localPosition = MadMath.Round(t.transform.localPosition);
                t.transform.localScale = new Vector3(1, 1, 1);
                EditorUtility.SetDirty(t);
            }
            
            if (!IsAnchored()) {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Anchor");
                if (GUILayout.Button("Create")) {
                    CreateAnchor();
                }
                EditorGUILayout.EndHorizontal();
            } else {
                var anchor = GetAnchor();
                var serAnchor = new SerializedObject(anchor);
                MadAnchorInspector.DrawInspector(serAnchor);
            }

            EditorGUI.BeginChangeCheck();
            t.pivot = (EnergyBar3DBase.Pivot) EditorGUILayout.EnumPopup("Pivot Point", t.pivot);
            if (EditorGUI.EndChangeCheck()) {
                EditorUtility.SetDirty(t);
            }
            
            MadGUI.PropertyField(guiDepth, "GUI Depth");
            MadGUI.EndBox();
        }
        
        if (MadGUI.Foldout("Appearance", false)) {
            MadGUI.BeginBox();
            
            MadGUI.PropertyField(repeatCount, "Repeat Count");
            MadGUI.PropertyFieldVector2(repeatPositionDelta, "Icon Distance");
            
            MadGUI.PropertyField(growType, "Grow Type");
            MadGUI.ConditionallyEnabled(growType.enumValueIndex == (int) RepeatedRenderer3D.GrowType.Fill, () => {
                MadGUI.PropertyField(fillDirection, "Fill Direction");
            });
            
            FieldLabel();
            
            MadGUI.EndBox();
        }
        
        if (MadGUI.Foldout("Effects", false)) {
            MadGUI.BeginBox();
            
            FieldSmoothEffect();
            
            MadGUI.EndBox();
        }
        
        EditorGUILayout.Space();
        
        serializedObject.ApplyModifiedProperties();
    }