public bool PEGI()
        {
            bool changed = false;

#if UNITY_EDITOR
            var painter = PlaytimePainter.inspectedPainter;
            inspectedAtlas = this;


            painter.SetOriginalShaderOnThis();

            Material mat = painter.GetMaterial(false);

            if ((mat != null) && ((mat != originalMaterial) || mat.shader != originalShader))
            {
                originalMaterial = mat;
                originalShader   = mat.shader;
                OnChangeMaterial(painter);
            }
            changed |= "Name".edit(50, ref name).nl();
            if ("Hint".foldout(ref showHint).nl())
            {
                ("If you don't set Atlased Material(Destination)  it will try to create a copy of current material and set isAtlased toggle on it, if it has one." +
                 " Below you can see: list of Texture Properties, for each you can select or create an atlas. Atlas is a class that holds all textures assigned to an atlas, and also creates and stores the atlas itself." +
                 "After this you can select a field from current Material, texture of which will be copied into an atlas. A bit confusing, I know)" +
                 "Also if stuff looks smudged, rebuild the light.").writeHint();
            }

            if (("Atlased Material:".edit(90, ref AtlasedMaterial).nl()) ||
                (AtlasedMaterial != null && AtlasedMaterial.shader != atlasedShader))
            {
                OnChangeMaterial(painter);
                changed = true;
            }

            if (painter != null)
            {
                var mats = painter.GetMaterials();
                if (mats != null)
                {
                    if (mats.Length > 1)
                    {
                        if ("Source Material:".select("Same as selecting a submesh, which will be converted", 90, ref painter.selectedSubmesh, mats))
                        {
                            changed = true;
                            OnChangeMaterial(painter);
                        }
                    }
                    else if (mats.Length > 0)
                    {
                        "Source Material".write("Submesh which will be converted", 90, mats[0]);
                    }
                }
                pegi.newLine();
                pegi.Space();
                pegi.newLine();
            }



            pegi.Space();
            pegi.newLine();

            foreach (var f in fields)
            {
                changed |= f.Nested_Inspect();
            }

            changed |= "Mesh Profile".select(110, ref matAtlasProfile, PainterCamera.Data.meshPackagingSolutions).nl();

            if ((DestinationMaterial != null) && (!DestinationMaterial.HasProperty(PainterDataAndConfig.isAtlasedProperty)))
            {
                if (AtlasedMaterial == null)
                {
                    pegi.writeHint("Original Material doesn't have isAtlased property, change shader or add Destination Atlased Material");
                }
                else
                {
                    pegi.writeHint("Atlased Material doesn't have isAtlased property");
                }
            }
            else if (originalMaterial != null)
            {
                string names = "";
                foreach (var f in fields)
                {
                    if (f.enabled && f.AtlasCreator == null)
                    {
                        names += f.atlasedField + ", ";
                    }
                }

                if (names.Length > 0)
                {
                    pegi.writeHint("Fields " + names + " don't have atlases assigned to them, create some");
                }
                else if ("Convert to Atlased".Click())
                {
                    ConvertToAtlased(painter);
                }
            }
#endif

            inspectedAtlas = null;

            return(changed);
        }
        public bool PEGI()
        {
            bool changed = false;

            MaterialAtlases a = MaterialAtlases.inspectedAtlas;

            changed |= atlasedField.toggle("Use this field", 50, ref enabled);

            if (enabled)
            {
                changed |= pegi.select(ref originField, a.originalTextures).nl();

                pegi.Space();

                if (AtlasCreator != null)
                {
                    "Atlas".foldout(ref foldoutAtlas);
                }

                else
                {
                    foldoutAtlas = false;
                }

                if (!foldoutAtlas)
                {
                    if (AtlasCreator != null)
                    {
                        changed |= "Color".toggle(35, ref AtlasCreator.sRGB);
                    }

                    pegi.select(ref atlasCreatorId, TileableAtlasingControllerPlugin.inst.atlases);
                    if (icon.Add.Click("Create new Atlas", 15).nl())
                    {
                        atlasCreatorId = TileableAtlasingControllerPlugin.inst.atlases.Count;
                        var ac = new AtlasTextureCreator(atlasedField + " for " + a.name);
                        TileableAtlasingControllerPlugin.inst.atlases.Add(ac);
                        changed = true;
                    }
                }
                else
                {
                    changed |= AtlasCreator.Nested_Inspect().nl();
                }



                pegi.Space();



                if ((atlasedField != null) && (a.originalMaterial != null) && (AtlasCreator != null) && (originField < a.originalTextures.Count))
                {
                    Texture t = a.originalMaterial.GetTexture(a.originalTextures[originField]);
                    if ((t != null) && t.GetType() == typeof(Texture2D)) //&& (atlasCreator.textures.Contains((Texture2D)t)))
                    {
                        icon.Done.write();
                    }
                    else
                    {
                        "Will use Color".edit(ref col).nl();
                    }
                }
                else
                {
                    "Color".edit("Color that will be used instead of a texture.", 35, ref col).nl();
                }
                pegi.Space();
            }


            pegi.newLine();
            pegi.Space();
            pegi.newLine();

            return(changed);
        }