Ejemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        MegaBookBuilder mod = (MegaBookBuilder)target;

        //serializedObject.Update();

        undoManager.CheckUndo();

#if !UNITY_5
        EditorGUIUtility.LookLikeControls();
#endif

        bool update     = false;
        bool updatemesh = false;

        if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName != null)
        {
            if (Event.current.commandName == "UndoRedoPerformed")
            {
                mod.rebuild = true;
            }
        }

        //if ( GUILayout.Button("Apply Scaling") )
        //{
        //mod.ApplyScaling();
        //}

        //EditorGUILayout.Slider(_prop_page, mod.MinPageVal(), mod.MaxPageVal(), new GUIContent("Page"));
        mod.page = EditorGUILayout.Slider("Page", mod.page, mod.MinPageVal(), mod.MaxPageVal());
        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();

            if (mod.linkeditpage)
            {
                mod.editpage = (int)(mod.page + 0.5f);
                mod.editpage = Mathf.Clamp(mod.editpage, 0, mod.pageparams.Count - 1);
            }

            mod.Flip    = mod.page;
            mod.turnspd = 0.0f;
            EditorUtility.SetDirty(target);
            GUI.changed = false;
        }

        //mod.shuffle = EditorGUILayout.FloatField("Shuffle", mod.shuffle);

        //EditorGUILayout.PropertyField(_prop_linkeditpage, new GUIContent("Link Edit Page"));
        //EditorGUILayout.PropertyField(_prop_snap, new GUIContent("Snap"));
        //EditorGUILayout.PropertyField(_prop_turntime, new GUIContent("Turn Time"));
        mod.linkeditpage = EditorGUILayout.Toggle("Link Edit Page", mod.linkeditpage);
        mod.Snap         = EditorGUILayout.Toggle("Snap", mod.Snap);
        mod.turntime     = EditorGUILayout.FloatField("Turn Time", mod.turntime);

        //int ival = mod.NumPages;
        //EditorGUILayout.PropertyField(_prop_numpages, new GUIContent("Num Pages"));

        int ival = EditorGUILayout.IntField("Num Pages", mod.NumPages);
        if (ival < 1)
        {
            ival = 1;
        }
        //if ( mod.NumPages < 1 )
        //mod.NumPages = 1;

        if (ival != mod.NumPages)
        {
            mod.NumPages = ival;
            updatemesh   = true;
        }

        float val  = 0.0f;
        bool  bval = false;

        mod.showmeshoptions = EditorGUILayout.Foldout(mod.showmeshoptions, "Mesh Options");

        if (mod.showmeshoptions)
        {
            EditorGUILayout.BeginVertical("box");
            val = EditorGUILayout.FloatField("Page Length", mod.pageLength);
            if (val < 0.0f)
            {
                val = 0.0f;
            }

            if (val != mod.pageLength)
            {
                mod.pageLength = val;
                updatemesh     = true;
            }

            val = EditorGUILayout.FloatField("Page Width", mod.pageWidth);
            if (val < 0.0f)
            {
                val = 0.0f;
            }
            if (val != mod.pageWidth)
            {
                mod.pageWidth = val;
                updatemesh    = true;
            }

            val = EditorGUILayout.FloatField("Page Height", mod.pageHeight);
            if (val < 0.0f)
            {
                val = 0.0f;
            }
            if (val != mod.pageHeight)
            {
                mod.pageHeight = val;
                updatemesh     = true;
            }

            ival = EditorGUILayout.IntField("Width Segs", mod.WidthSegs);
            if (ival != mod.WidthSegs)
            {
                mod.WidthSegs = ival;
                updatemesh    = true;
            }

            ival = EditorGUILayout.IntField("Length Segs", mod.LengthSegs);
            if (ival != mod.LengthSegs)
            {
                mod.LengthSegs = ival;
                updatemesh     = true;
            }

            ival = EditorGUILayout.IntField("Height Segs", mod.HeightSegs);
            if (ival != mod.HeightSegs)
            {
                mod.HeightSegs = ival;
                updatemesh     = true;
            }

            bval = EditorGUILayout.Toggle("Spine Edge", mod.spineedge);
            if (bval != mod.spineedge)
            {
                mod.spineedge = bval;
                updatemesh    = true;
            }

            bval = EditorGUILayout.Toggle("Page Hole Mesh", mod.useholepage);
            if (bval != mod.useholepage)
            {
                mod.useholepage = bval;
                updatemesh      = true;
            }

            ival = EditorGUILayout.IntField("X Hole", mod.xhole);
            if (ival != mod.xhole)
            {
                mod.xhole  = ival;
                updatemesh = true;
            }

            ival = EditorGUILayout.IntField("Y Hole", mod.yhole);
            if (ival != mod.yhole)
            {
                mod.yhole  = ival;
                updatemesh = true;
            }

            mod.pagesizevariation = EditorGUILayout.Vector3Field("Variation", mod.pagesizevariation);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.pagesectioncrv = EditorGUILayout.CurveField("Vertex Dist", mod.pagesectioncrv);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.pagemesh = (Mesh)EditorGUILayout.ObjectField("Page Mesh", mod.pagemesh, typeof(Mesh), true);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.holemesh = (Mesh)EditorGUILayout.ObjectField("Hole Mesh", mod.holemesh, typeof(Mesh), true);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.pageobject = (GameObject)EditorGUILayout.ObjectField("Page Object", mod.pageobject, typeof(GameObject), false);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.holeobject = (GameObject)EditorGUILayout.ObjectField("Hole Object", mod.holeobject, typeof(GameObject), false);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.frontmat = EditorGUILayout.IntField("Front Mat ID", mod.frontmat);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.backmat = EditorGUILayout.IntField("Back Mat ID", mod.backmat);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.rotate = EditorGUILayout.Vector3Field("Rotate", mod.rotate);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.basematerial = (Material)EditorGUILayout.ObjectField("Front Material", mod.basematerial, typeof(Material), true);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.basematerial1 = (Material)EditorGUILayout.ObjectField("Back Material", mod.basematerial1, typeof(Material), true);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.basematerial2 = (Material)EditorGUILayout.ObjectField("Edge Material", mod.basematerial2, typeof(Material), true);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            val = EditorGUILayout.FloatField("Page Gap", mod.pageGap);
            if (val != mod.pageGap)
            {
                mod.pageGap = val;
                update      = true;
            }

            val = EditorGUILayout.Slider("Spine Radius", mod.spineradius, -1.0f, 1.0f);
            if (val != mod.spineradius)
            {
                mod.spineradius = val;
                update          = true;
            }

            bval = EditorGUILayout.Toggle("Use Book Thickness", mod.usebookthickness);
            if (bval != mod.usebookthickness)
            {
                mod.usebookthickness = bval;
                update = true;
            }

            val = EditorGUILayout.FloatField("Book Thickness", mod.bookthickness);
            if (val != mod.bookthickness)
            {
                mod.bookthickness = val;
                update            = true;
            }

            bval = EditorGUILayout.Toggle("Page Colliders", mod.updatecollider);
            if (bval != mod.updatecollider)
            {
                mod.updatecollider = bval;
                updatemesh         = true;
            }

            bval = EditorGUILayout.BeginToggleGroup("Allow Color", mod.usecols);
            if (bval != mod.usecols)
            {
                mod.usecols = bval;
                updatemesh  = true;
            }

            Color col = EditorGUILayout.ColorField("Color", mod.color);
            if (col != mod.color)
            {
                mod.color  = col;
                updatemesh = true;
            }

            bval = EditorGUILayout.Toggle("Cast Shadows", mod.castshadows);
            if (bval != mod.castshadows)
            {
                mod.castshadows = bval;
                updatemesh      = true;
            }

            bval = EditorGUILayout.Toggle("Receive Shadows", mod.receiveshadows);
            if (bval != mod.receiveshadows)
            {
                mod.receiveshadows = bval;
                updatemesh         = true;
            }

            bval = EditorGUILayout.Toggle("Use Light Probes", mod.uselightprobes);
            if (bval != mod.uselightprobes)
            {
                mod.uselightprobes = bval;
                updatemesh         = true;
            }

            EditorGUILayout.EndToggleGroup();

            EditorGUILayout.EndVertical();
        }

        mod.showflipoptions = EditorGUILayout.Foldout(mod.showflipoptions, "Page Turn Options");

        if (mod.showflipoptions)
        {
            EditorGUILayout.BeginVertical("box");
            mod.BottomAngle      = EditorGUILayout.FloatField("Spine Angle", mod.BottomAngle);
            mod.BottomMaxAngle   = EditorGUILayout.FloatField("Max Spine Angle", mod.BottomMaxAngle);
            mod.changespineangle = EditorGUILayout.Toggle("Change Spine Angle", mod.changespineangle);

            float center = EditorGUILayout.Slider("Turn Center", mod.Turn_CCenter, 0.0f, 1.0f);
            if (center != mod.Turn_CCenter)
            {
                mod.Turn_CCenter = center;
                update           = true;
            }

            val = EditorGUILayout.Slider("Turn Size", mod.Turn_CArea, 0.01f, 1.0f);
            if (val != mod.Turn_CArea)
            {
                mod.Turn_CAreaChange(val);
            }

            val = EditorGUILayout.FloatField("Turn Max Angle", mod.Turn_maxAngle);
            if (val != mod.Turn_maxAngle)
            {
                mod.Turn_maxAngleChange(val);
            }

            val = EditorGUILayout.FloatField("Turn Min Angle", mod.Turn_minAngle);
            if (val != mod.Turn_minAngle)
            {
                mod.Turn_minAngleChange(val);
            }

            val = EditorGUILayout.FloatField("Turn Spread", mod.Turn_Spread);
            if (val != mod.Turn_Spread)
            {
                mod.Turn_SpreadChange(val);
            }

            val = EditorGUILayout.Slider("Open Origin", mod.Land_CCenter, 0.0f, 1.0f);
            if (val != mod.Land_CCenter)
            {
                mod.Land_CCenterChange(val);
            }

            val = EditorGUILayout.Slider("Open Size", mod.Land_CArea, 0.01f, 1.0f);
            if (val != mod.Land_CArea)
            {
                mod.Land_CAreaChange(val);
            }

            val = EditorGUILayout.FloatField("Open Max Angle", mod.Land_maxAngle);
            if (val != mod.Land_maxAngle)
            {
                mod.Land_MaxAngleChange(val);
            }

            val = EditorGUILayout.FloatField("Open Min Angle", mod.Land_minAngle);
            if (val != mod.Land_minAngle)
            {
                mod.Land_MinAngleChange(val);
            }

            val = EditorGUILayout.Slider("Flip Origin", mod.Flex_CCenter, 0.0f, 1.0f);
            if (val != mod.Flex_CCenter)
            {
                mod.Flex_CCenterChange(val);
            }

            val = EditorGUILayout.Slider("Flip Size", mod.Flex_CArea, 0.01f, 1.0f);
            if (val != mod.Flex_CArea)
            {
                mod.Flex_CAreaChange(val);
            }

            val = EditorGUILayout.FloatField("Flip Max Angle", mod.Flex_MaxAngle);
            if (val != mod.Flex_MaxAngle)
            {
                mod.Flex_MaxAngleChange(val);
            }

            bval = EditorGUILayout.Toggle("Flip Random", mod.Flex_Random);
            if (bval != mod.Flex_Random)
            {
                mod.Flex_RandomChange(mod.Flex_RandomDegree, mod.Flex_RandomSeed, bval);
            }

            ival = EditorGUILayout.IntField("Flip Random Seed", mod.Flex_RandomSeed);
            if (ival != mod.Flex_RandomSeed)
            {
                mod.Flex_RandomChange(mod.Flex_RandomDegree, ival, bval);
            }

            val = EditorGUILayout.FloatField("Flip Random Ang", mod.Flex_RandomDegree);
            if (val != mod.Flex_RandomDegree)
            {
                mod.Flex_RandomChange(val, mod.Flex_RandomSeed, mod.Flex_Random);
            }

            EditorGUILayout.EndVertical();
        }

        mod.showmaterials = EditorGUILayout.Foldout(mod.showmaterials, "Pages");

        if (mod.showmaterials && mod.pageparams.Count > 0)
        {
            if (mod.pageparams.Count > 1)
            {
                mod.editpage = EditorGUILayout.IntSlider("Edit Page", mod.editpage, 0, mod.pageparams.Count - 1);
                //mod.editpage = EditorGUILayout.IntSlider("Edit Page", mod.editpage, 0, mod.NumPages - 1);	//mod.MinPageVal(), mod.MaxPageVal());
            }

            if (GUILayout.Button("Add Page"))
            {
                mod.pageparams.Add(NewPage(mod.pageparams.Count - 1));
            }

            EditorGUILayout.BeginVertical("box");
            if (DisplayPage(mod.pageparams[mod.editpage], mod.editpage))
            {
                updatemesh = true;
            }

            EditorGUILayout.EndVertical();

            if (GUILayout.Button("Add Page"))
            {
                mod.pageparams.Add(NewPage(mod.pageparams.Count - 1));
            }
        }
        else
        if (GUILayout.Button("Add Page"))
        {
            mod.pageparams.Add(NewPage(mod.pageparams.Count - 1));
        }

        mod.showbackgrounds = EditorGUILayout.Foldout(mod.showbackgrounds, "Texture Backgrounds");

        if (mod.showbackgrounds)
        {
            EditorGUILayout.BeginVertical("box");
            bool noback = EditorGUILayout.Toggle("No Backgrounds", mod.nobackgrounds);
            if (noback != mod.nobackgrounds)
            {
                mod.nobackgrounds = noback;
                update            = true;
            }

            Texture2D tex = (Texture2D)EditorGUILayout.ObjectField("Background", mod.background, typeof(Texture2D), false);

            if (tex != mod.background && CheckTextureReadable(tex))
            {
                if (tex == null)
                {
                    mod.ClearMadeTextures();
                    update = true;
                }
                mod.background = tex;
            }

            tex = (Texture2D)EditorGUILayout.ObjectField("Background Back", mod.background1, typeof(Texture2D), false);

            if (tex != mod.background1 && CheckTextureReadable(tex))
            {
                if (tex == null)
                {
                    mod.ClearMadeTextures();
                    update = true;
                }
                mod.background1 = tex;
            }

            tex = (Texture2D)EditorGUILayout.ObjectField("Mask", mod.mask, typeof(Texture2D), false);

            if (tex != mod.mask && CheckTextureReadable(tex))
            {
                if (tex == null)
                {
                    mod.ClearMadeTextures();
                    update = true;
                }
                mod.mask = tex;
            }

            Rect copyarea = EditorGUILayout.RectField("Copy Area", mod.copyarea);
            if (copyarea != mod.copyarea)
            {
                mod.copyarea = copyarea;
                mod.ClearMadeTextures();
                update = true;
            }

            copyarea = EditorGUILayout.RectField("Copy Area Back", mod.copyarea1);
            if (copyarea != mod.copyarea1)
            {
                mod.copyarea1 = copyarea;
                mod.ClearMadeTextures();
                update = true;
            }

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Clear"))
            {
                mod.ClearMadeTextures();
                updatemesh = true;
            }

            if (GUILayout.Button("Make Pages"))
            {
                mod.BuildPageTextures();
                updatemesh = true;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }

        mod.showcover = EditorGUILayout.Foldout(mod.showcover, "Cover Params");

        if (mod.showcover)
        {
            EditorGUILayout.BeginVertical("box");
            mod.frontcover = (Transform)EditorGUILayout.ObjectField("Front Cover", mod.frontcover, typeof(Transform), true);
            mod.frontang   = EditorGUILayout.FloatField("Front Ang", mod.frontang);
            mod.frontpivot = EditorGUILayout.Vector3Field("Front Pivot", mod.frontpivot);
            mod.backcover  = (Transform)EditorGUILayout.ObjectField("Back Cover", mod.backcover, typeof(Transform), true);
            mod.backang    = EditorGUILayout.FloatField("Back Ang", mod.backang);
            mod.backpivot  = EditorGUILayout.Vector3Field("Back Pivot", mod.backpivot);
            EditorGUILayout.EndVertical();
        }

        mod.showdynammesh = EditorGUILayout.Foldout(mod.showdynammesh, "Dynam Mesh");

        if (mod.showdynammesh)
        {
            EditorGUILayout.BeginVertical("box");
            bool texton = EditorGUILayout.BeginToggleGroup("Enabled", mod.dynammeshenabled);
            if (texton != mod.dynammeshenabled)
            {
                mod.dynammeshenabled = texton;
                updatemesh           = true;
            }
            MegaBookDynamicMesh textobj = (MegaBookDynamicMesh)EditorGUILayout.ObjectField("Text Object", mod.dynamobj, typeof(MegaBookDynamicMesh), true);
            if (textobj != mod.dynamobj)
            {
                mod.dynamobj = textobj;
                updatemesh   = true;
            }

            EditorGUILayout.BeginVertical("box");
            Vector3 textoffset = EditorGUILayout.Vector3Field("Front Offset", mod.dynamoffset);
            if (textoffset != mod.dynamoffset)
            {
                mod.dynamoffset = textoffset;
                updatemesh      = true;
            }

            Vector3 textrot = EditorGUILayout.Vector3Field("Front Rotate", mod.dynamrot);
            if (textrot != mod.dynamrot)
            {
                mod.dynamrot = textrot;
                updatemesh   = true;
            }

            Vector3 textscale = EditorGUILayout.Vector3Field("Front Scale", mod.dynamscale);
            if (textscale != mod.dynamscale)
            {
                mod.dynamscale = textscale;
                updatemesh     = true;
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("box");
            textoffset = EditorGUILayout.Vector3Field("Back Offset", mod.backdynamoffset);
            if (textoffset != mod.backdynamoffset)
            {
                mod.backdynamoffset = textoffset;
                updatemesh          = true;
            }

            textrot = EditorGUILayout.Vector3Field("Back Rotate", mod.backdynamrot);
            if (textrot != mod.backdynamrot)
            {
                mod.backdynamrot = textrot;
                updatemesh       = true;
            }

            textscale = EditorGUILayout.Vector3Field("Back Scale", mod.backdynamscale);
            if (textscale != mod.backdynamscale)
            {
                mod.backdynamscale = textscale;
                updatemesh         = true;
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndToggleGroup();
            EditorGUILayout.EndVertical();
        }

        if (GUILayout.Button("Rebuild"))
        {
            updatemesh  = true;
            mod.rebuild = true;
            EditorUtility.SetDirty(target);
        }

        if (updatemesh)
        {
            mod.rebuildmeshes = true;
            //mod.UpdateSettings();
            //mod.Detach();
            //mod.BuildPageMeshes();
            //mod.Attach();
            //mod.UpdateSettings();
        }

        // debug
        for (int i = 0; i < mod.pages.Count; i++)
        {
            mod.pages[i].turnerfromcon = EditorGUILayout.CurveField("Turn", mod.pages[i].turnerfromcon);
        }

        //for ( int i = 0; i < mod.pages.Count; i++ )
        //{
        //mod.pages[i].turnerangcon = EditorGUILayout.CurveField("Ang", mod.pages[i].turnerangcon);
        //}

        if (update)
        {
            mod.UpdateSettings();
        }

        if (GUI.changed)
        {
            //serializedObject.ApplyModifiedProperties();

            if (mod.pages.Count > 0)
            {
                mod.pages[0].deform = true;
            }
            EditorUtility.SetDirty(target);
        }

        undoManager.CheckDirty();
    }
Ejemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        MegaBookBuilder mod = (MegaBookBuilder)target;

        undoManager.CheckUndo();

        EditorGUIUtility.LookLikeControls();

        bool update     = false;
        bool updatemesh = false;

        if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName != null)
        {
            if (Event.current.commandName == "UndoRedoPerformed")
            {
                mod.rebuild = true;
            }
        }

        mod.page = EditorGUILayout.Slider("Page", mod.page, 0.0f, (float)mod.NumPages);
        if (GUI.changed)
        {
            mod.Flip    = mod.page;
            mod.turnspd = 0.0f;
            EditorUtility.SetDirty(target);
            GUI.changed = false;
        }

        mod.Snap     = EditorGUILayout.Toggle("Snap", mod.Snap);
        mod.turntime = EditorGUILayout.FloatField("Turn Time", mod.turntime);

        int ival = EditorGUILayout.IntField("Num Pages", mod.NumPages);

        if (ival < 1)
        {
            ival = 1;
        }

        if (ival != mod.NumPages)
        {
            mod.NumPages = ival;
            updatemesh   = true;
        }

        float val  = 0.0f;
        bool  bval = false;

        mod.showmeshoptions = EditorGUILayout.Foldout(mod.showmeshoptions, "Mesh Options");

        if (mod.showmeshoptions)
        {
            EditorGUILayout.BeginVertical("box");
            val = EditorGUILayout.FloatField("Page Length", mod.pageLength);
            if (val < 0.0f)
            {
                val = 0.0f;
            }

            if (val != mod.pageLength)
            {
                mod.pageLength = val;
                updatemesh     = true;
            }

            val = EditorGUILayout.FloatField("Page Width", mod.pageWidth);
            if (val < 0.0f)
            {
                val = 0.0f;
            }
            if (val != mod.pageWidth)
            {
                mod.pageWidth = val;
                updatemesh    = true;
            }

            val = EditorGUILayout.FloatField("Page Height", mod.pageHeight);
            if (val < 0.0f)
            {
                val = 0.0f;
            }
            if (val != mod.pageHeight)
            {
                mod.pageHeight = val;
                updatemesh     = true;
            }

            ival = EditorGUILayout.IntField("Width Segs", mod.WidthSegs);
            if (ival != mod.WidthSegs)
            {
                mod.WidthSegs = ival;
                updatemesh    = true;
            }

            ival = EditorGUILayout.IntField("Length Segs", mod.LengthSegs);
            if (ival != mod.LengthSegs)
            {
                mod.LengthSegs = ival;
                updatemesh     = true;
            }

            ival = EditorGUILayout.IntField("Height Segs", mod.HeightSegs);
            if (ival != mod.HeightSegs)
            {
                mod.HeightSegs = ival;
                updatemesh     = true;
            }

            bval = EditorGUILayout.Toggle("Spine Edge", mod.spineedge);
            if (bval != mod.spineedge)
            {
                mod.spineedge = bval;
                updatemesh    = true;
            }

            bval = EditorGUILayout.Toggle("Page Hole Mesh", mod.useholepage);
            if (bval != mod.useholepage)
            {
                mod.useholepage = bval;
                updatemesh      = true;
            }

            ival = EditorGUILayout.IntField("X Hole", mod.xhole);
            if (ival != mod.xhole)
            {
                mod.xhole  = ival;
                updatemesh = true;
            }

            ival = EditorGUILayout.IntField("Y Hole", mod.yhole);
            if (ival != mod.yhole)
            {
                mod.yhole  = ival;
                updatemesh = true;
            }

            mod.pagesizevariation = EditorGUILayout.Vector3Field("Variation", mod.pagesizevariation);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.pagesectioncrv = EditorGUILayout.CurveField("Vertex Dist", mod.pagesectioncrv);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.pagemesh = (Mesh)EditorGUILayout.ObjectField("Page Mesh", mod.pagemesh, typeof(Mesh), true);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.holemesh = (Mesh)EditorGUILayout.ObjectField("Hole Mesh", mod.holemesh, typeof(Mesh), true);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.pageobject = (GameObject)EditorGUILayout.ObjectField("Page Object", mod.pageobject, typeof(GameObject), false);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.holeobject = (GameObject)EditorGUILayout.ObjectField("Hole Object", mod.holeobject, typeof(GameObject), false);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.frontmat = EditorGUILayout.IntField("Front Mat ID", mod.frontmat);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.backmat = EditorGUILayout.IntField("Back Mat ID", mod.backmat);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.rotate = EditorGUILayout.Vector3Field("Rotate", mod.rotate);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.basematerial = (Material)EditorGUILayout.ObjectField("Front Material", mod.basematerial, typeof(Material), true);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.basematerial1 = (Material)EditorGUILayout.ObjectField("Back Material", mod.basematerial1, typeof(Material), true);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            mod.basematerial2 = (Material)EditorGUILayout.ObjectField("Edge Material", mod.basematerial2, typeof(Material), true);
            if (GUI.changed)
            {
                updatemesh = true;
            }

            val = EditorGUILayout.FloatField("Page Gap", mod.pageGap);
            if (val != mod.pageGap)
            {
                mod.pageGap = val;
                update      = true;
            }

            val = EditorGUILayout.Slider("Spine Radius", mod.spineradius, -1.0f, 1.0f);
            if (val != mod.spineradius)
            {
                mod.spineradius = val;
                update          = true;
            }

            bval = EditorGUILayout.Toggle("Use Book Thickness", mod.usebookthickness);
            if (bval != mod.usebookthickness)
            {
                mod.usebookthickness = bval;
                update = true;
            }

            val = EditorGUILayout.FloatField("Book Thickness", mod.bookthickness);
            if (val != mod.bookthickness)
            {
                mod.bookthickness = val;
                update            = true;
            }

            bval = EditorGUILayout.Toggle("Page Colliders", mod.updatecollider);
            if (bval != mod.updatecollider)
            {
                mod.updatecollider = bval;
                updatemesh         = true;
            }

            EditorGUILayout.EndVertical();
        }

        mod.showflipoptions = EditorGUILayout.Foldout(mod.showflipoptions, "Page Turn Options");

        if (mod.showflipoptions)
        {
            EditorGUILayout.BeginVertical("box");
            mod.BottomAngle      = EditorGUILayout.FloatField("Spine Angle", mod.BottomAngle);
            mod.BottomMaxAngle   = EditorGUILayout.FloatField("Max Spine Angle", mod.BottomMaxAngle);
            mod.changespineangle = EditorGUILayout.Toggle("Change Spine Angle", mod.changespineangle);

            float center = EditorGUILayout.Slider("Turn Center", mod.Turn_CCenter, 0.0f, 1.0f);
            if (center != mod.Turn_CCenter)
            {
                mod.Turn_CCenter = center;
                update           = true;
            }

            val = EditorGUILayout.Slider("Turn Size", mod.Turn_CArea, 0.01f, 1.0f);
            if (val != mod.Turn_CArea)
            {
                mod.Turn_CAreaChange(val);
            }

            val = EditorGUILayout.FloatField("Turn Max Angle", mod.Turn_maxAngle);
            if (val != mod.Turn_maxAngle)
            {
                mod.Turn_maxAngleChange(val);
            }

            val = EditorGUILayout.FloatField("Turn Min Angle", mod.Turn_minAngle);
            if (val != mod.Turn_minAngle)
            {
                mod.Turn_minAngleChange(val);
            }

            val = EditorGUILayout.FloatField("Turn Spread", mod.Turn_Spread);
            if (val != mod.Turn_Spread)
            {
                mod.Turn_SpreadChange(val);
            }

            val = EditorGUILayout.Slider("Open Origin", mod.Land_CCenter, 0.0f, 1.0f);
            if (val != mod.Land_CCenter)
            {
                mod.Land_CCenterChange(val);
            }

            val = EditorGUILayout.Slider("Open Size", mod.Land_CArea, 0.01f, 1.0f);
            if (val != mod.Land_CArea)
            {
                mod.Land_CAreaChange(val);
            }

            val = EditorGUILayout.FloatField("Open Max Angle", mod.Land_maxAngle);
            if (val != mod.Land_maxAngle)
            {
                mod.Land_MaxAngleChange(val);
            }

            val = EditorGUILayout.FloatField("Open Min Angle", mod.Land_minAngle);
            if (val != mod.Land_minAngle)
            {
                mod.Land_MinAngleChange(val);
            }

            val = EditorGUILayout.Slider("Flip Origin", mod.Flex_CCenter, 0.0f, 1.0f);
            if (val != mod.Flex_CCenter)
            {
                mod.Flex_CCenterChange(val);
            }

            val = EditorGUILayout.Slider("Flip Size", mod.Flex_CArea, 0.01f, 1.0f);
            if (val != mod.Flex_CArea)
            {
                mod.Flex_CAreaChange(val);
            }

            val = EditorGUILayout.FloatField("Flip Max Angle", mod.Flex_MaxAngle);
            if (val != mod.Flex_MaxAngle)
            {
                mod.Flex_MaxAngleChange(val);
            }

            bval = EditorGUILayout.Toggle("Flip Random", mod.Flex_Random);
            if (bval != mod.Flex_Random)
            {
                mod.Flex_RandomChange(mod.Flex_RandomDegree, mod.Flex_RandomSeed, bval);
            }

            ival = EditorGUILayout.IntField("Flip Random Seed", mod.Flex_RandomSeed);
            if (ival != mod.Flex_RandomSeed)
            {
                mod.Flex_RandomChange(mod.Flex_RandomDegree, ival, bval);
            }

            val = EditorGUILayout.FloatField("Flip Random Ang", mod.Flex_RandomDegree);
            if (val != mod.Flex_RandomDegree)
            {
                mod.Flex_RandomChange(val, mod.Flex_RandomSeed, mod.Flex_Random);
            }

            EditorGUILayout.EndVertical();
        }

        mod.showmaterials = EditorGUILayout.Foldout(mod.showmaterials, "Pages");

        if (mod.showmaterials)
        {
            mod.editpage = EditorGUILayout.IntSlider("Edit Page", mod.editpage, 0, mod.pageparams.Count - 1);

            if (GUILayout.Button("Add Page"))
            {
                mod.pageparams.Add(NewPage(mod.pageparams.Count - 1));
            }

            EditorGUILayout.BeginVertical("box");
            if (DisplayPage(mod.pageparams[mod.editpage], mod.editpage))
            {
                updatemesh = true;
            }

            EditorGUILayout.EndVertical();

            if (GUILayout.Button("Add Page"))
            {
                mod.pageparams.Add(NewPage(mod.pageparams.Count - 1));
            }
        }

        mod.showbackgrounds = EditorGUILayout.Foldout(mod.showbackgrounds, "Texture Backgrounds");

        if (mod.showbackgrounds)
        {
            EditorGUILayout.BeginVertical("box");
            bool noback = EditorGUILayout.Toggle("No Backgrounds", mod.nobackgrounds);
            if (noback != mod.nobackgrounds)
            {
                mod.nobackgrounds = noback;
                update            = true;
            }

            Texture2D tex = (Texture2D)EditorGUILayout.ObjectField("Background", mod.background, typeof(Texture2D), false);

            if (tex != mod.background && CheckTextureReadable(tex))
            {
                if (tex == null)
                {
                    mod.ClearMadeTextures();
                    update = true;
                }
                mod.background = tex;
            }

            tex = (Texture2D)EditorGUILayout.ObjectField("Background Back", mod.background1, typeof(Texture2D), false);

            if (tex != mod.background1 && CheckTextureReadable(tex))
            {
                if (tex == null)
                {
                    mod.ClearMadeTextures();
                    update = true;
                }
                mod.background1 = tex;
            }

            tex = (Texture2D)EditorGUILayout.ObjectField("Mask", mod.mask, typeof(Texture2D), false);

            if (tex != mod.mask && CheckTextureReadable(tex))
            {
                if (tex == null)
                {
                    mod.ClearMadeTextures();
                    update = true;
                }
                mod.mask = tex;
            }

            Rect copyarea = EditorGUILayout.RectField("Copy Area", mod.copyarea);
            if (copyarea != mod.copyarea)
            {
                mod.copyarea = copyarea;
                mod.ClearMadeTextures();
                update = true;
            }

            copyarea = EditorGUILayout.RectField("Copy Area Back", mod.copyarea1);
            if (copyarea != mod.copyarea1)
            {
                mod.copyarea1 = copyarea;
                mod.ClearMadeTextures();
                update = true;
            }

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Clear"))
            {
                mod.ClearMadeTextures();
                updatemesh = true;
            }

            if (GUILayout.Button("Make Pages"))
            {
                mod.BuildPageTextures();
                updatemesh = true;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }

        if (updatemesh)
        {
            mod.UpdateSettings();
            mod.Detach();
            mod.BuildPageMeshes();
            mod.Attach();
            mod.UpdateSettings();
        }

        if (update)
        {
            mod.UpdateSettings();
        }

        if (GUILayout.Button("Rebuild"))
        {
            mod.rebuild = true;
            EditorUtility.SetDirty(target);
        }

        if (GUI.changed)
        {
            if (mod.pages.Count > 0)
            {
                mod.pages[0].deform = true;
            }
            EditorUtility.SetDirty(target);
        }

        undoManager.CheckDirty();
    }