Internal static classes result in a very big script. How can I create them dynamically?

I have a big time consuming problem. I have had this project on the back burner for a few yeas and figured I should dip my toes back into it and ask some questions. Working on a console for my game and have run into this issue. At the moment the main part of this script is over 9000 lines dues to this problem.

I am creating internal static classes that end up being very long. I need a way to condense this code to reduce to workload of hardcoding the rest of these chunks.

How can i pass the internal static name when Set3DTextProperties() is called? the internal static class is posted below this first chunk of code.

I need threedtext.name, threedtext.vector3 ect to change to whatever.name, whatever.vector3
I changed a few values as a example.

This way I can use a universal bit of code to pass a string and have the matching internal static class link up properly.

I have over 50 of these hard coded currently and have another 30 to go and would like to save some time. :slight_smile:

public void Set3DTextProperties (string whatever)
    {

        newpropertyelement.name = threedtext.name;
        newpropertyelement.vector3 = threedtext.vector3;
        newpropertyelement.v3rotation = whatever.v3rotation;
        newpropertyelement.v3scale = whatever.v3scale;
        newpropertyelement.text = whatever.text;
        newpropertyelement.font = whatever.font;
        newpropertyelement.fontsize = whatever.fontsize;
        newpropertyelement.ecfilelocation = whatever.ecfilelocation;
        newpropertyelement.texturename = whatever.texturename;
        newpropertyelement.texturelocation = whatever.texturelocation;
        newpropertyelement.audioname = threedtext.audioname;
        newpropertyelement.audiolocation = threedtext.audiolocation;
        newpropertyelement.spritename = threedtext.spritename;
        newpropertyelement.spritelocation = threedtext.spritelocation;
        newpropertyelement.radius = threedtext.radius;
        newpropertyelement.ecvector2 = threedtext.ecvector2;
        newpropertyelement.v2scale = threedtext.v2scale;
        newpropertyelement.offsetX = threedtext.offsetX;
        newpropertyelement.offsetY = threedtext.offsetY;
        newpropertyelement.offsetZ = threedtext.offsetZ;
        newpropertyelement.depth = threedtext.depth;
        newpropertyelement.terrainscale = threedtext.terrainscale;
        newpropertyelement.shadername = threedtext.shadername;
        newpropertyelement.shaderdropdown = threedtext.shaderdropdown;
        newpropertyelement.pixelper = threedtext.pixelper;
        newpropertyelement.cellsize = threedtext.cellsize;
        newpropertyelement.cellgap = threedtext.cellgap;
        newpropertyelement.cellswizzle = threedtext.cellswizzle;
        newpropertyelement.cliplocation = threedtext.cliplocation;
        newpropertyelement.windmode = threedtext.windmode;
        newpropertyelement.windmain = threedtext.windmain;
        newpropertyelement.pulsefreq = threedtext.pulsefreq;
        newpropertyelement.pulsemag = threedtext.pulsemag;
        newpropertyelement.pulseturb = threedtext.pulseturb;
        newpropertyelement.fromraycast = threedtext.fromraycast;
        newpropertyelement.toraycast = threedtext.toraycast;
        newpropertyelement.width = threedtext.width;
        newpropertyelement.height = threedtext.height;
        newpropertyelement.minwidth = threedtext.minwidth;
        newpropertyelement.minheight = threedtext.minheight;
        newpropertyelement.maxwidth = threedtext.maxwidth;
        newpropertyelement.maxheight = threedtext.maxheight;
        newpropertyelement.padding = threedtext.padding;
        newpropertyelement.paddingx = threedtext.paddingx;
        newpropertyelement.paddingy = threedtext.paddingy;
        newpropertyelement.paddingz = threedtext.paddingz;
        newpropertyelement.rgbred = threedtext.rgbred;
        newpropertyelement.rgbgreen = threedtext.rgbgreen;
        newpropertyelement.rgbblue = threedtext.rgbblue;
        newpropertyelement.ecchildname = threedtext.ecchildname;
        newpropertyelement.ecchildindex = threedtext.ecchildindex;
        newpropertyelement.parentthisobject = threedtext.parentthisobject;
        newpropertyelement.ecparentindex = threedtext.ecparentindex;
        newpropertyelement.ecdensity = threedtext.ecdensity;
        newpropertyelement.ecintensity = threedtext.ecintensity;
        newpropertyelement.ecsaturation = threedtext.ecsaturation;

        newpropertyelement.maxdistance = threedtext.maxdistance;
        newpropertyelement.mindistance = threedtext.mindistance;
        newpropertyelement.reverbpreset = threedtext.reverbpreset;
        newpropertyelement.room = threedtext.room;
        newpropertyelement.roomhf = threedtext.roomhf;
        newpropertyelement.roomlf = threedtext.roomlf;
        newpropertyelement.decaytime = threedtext.decaytime;
        newpropertyelement.decayhfratio = threedtext.decayhfratio;
        newpropertyelement.reverbreflections = threedtext.reverbreflections;
        newpropertyelement.reverb = threedtext.reverb;
        newpropertyelement.reverbdelay = threedtext.reverbdelay;
        newpropertyelement.hfreference = threedtext.hfreference;
        newpropertyelement.lfreference = threedtext.lfreference;
        newpropertyelement.diffusion = threedtext.diffusion;
        newpropertyelement.bgrgbred = threedtext.bgrgbred;
        newpropertyelement.bgrgbgreen = threedtext.bgrgbgreen;
        newpropertyelement.bgrgbblue = threedtext.bgrgbblue;
        newpropertyelement.density = threedtext.density;

        newpropertyelement.clearflags = threedtext.clearflags;
        newpropertyelement.background = threedtext.background;
        newpropertyelement.cullingmask = threedtext.cullingmask;
        newpropertyelement.projection = threedtext.projection;
        newpropertyelement.fieldofview = threedtext.fieldofview;
        newpropertyelement.nearclipping = threedtext.nearclipping;
        newpropertyelement.farclipping = threedtext.farclipping;
        newpropertyelement.viewportrectx = threedtext.viewportrectx;
        newpropertyelement.viewportrecty = threedtext.viewportrecty;
        newpropertyelement.viewportrectw = threedtext.viewportrectw;
        newpropertyelement.viewportrecth = threedtext.viewportrecth;
        newpropertyelement.renderingpath = threedtext.renderingpath;
        newpropertyelement.targettexture = threedtext.targettexture;
        newpropertyelement.ecocclusioncolling = threedtext.ecocclusioncolling;
        newpropertyelement.ecallowhdr = threedtext.ecallowhdr;
        newpropertyelement.ecallowmsaa = threedtext.ecallowmsaa;
        newpropertyelement.ecallowdynamicres = threedtext.ecallowdynamicres;
        newpropertyelement.targetdisply = threedtext.targetdisply;

        //Directional Light
        newpropertyelement.indirectmultiplier = threedtext.indirectmultiplier;

        newpropertyelement.lightmode = threedtext.lightmode;

        newpropertyelement.shadowtype = threedtext.shadowtype;
        newpropertyelement.eccookie = threedtext.eccookie;
        newpropertyelement.eccookiesize = threedtext.eccookiesize;
        newpropertyelement.ecshadowtype = threedtext.ecshadowtype;
        newpropertyelement.drawhalo = threedtext.drawhalo;
        newpropertyelement.eclightflare = threedtext.eclightflare;
        newpropertyelement.lightrendermode = threedtext.lightrendermode;

        newpropertyelement.showwireframe = threedtext.showwireframe;
        newpropertyelement.probeposx = threedtext.probeposx;
        newpropertyelement.probeposy = threedtext.probeposy;
        newpropertyelement.probeposz = threedtext.probeposy;
        newpropertyelement.addprobebtn = threedtext.probeposz;
        newpropertyelement.deleteprobebtn = threedtext.deleteprobebtn;
        newpropertyelement.selectallprobesbtn = threedtext.selectallprobesbtn;
        newpropertyelement.duplicateprobesbtn = threedtext.duplicateprobesbtn;

        //Line Effect
        newpropertyelement.eccastshadows = threedtext.eccastshadows;
        newpropertyelement.ecrecieveshadows = threedtext.ecrecieveshadows;
        newpropertyelement.ecdynocc = threedtext.ecdynocc;
        newpropertyelement.ecmotionvectors = threedtext.ecmotionvectors;
        newpropertyelement.eclinepositions = threedtext.eclinepositions;
        newpropertyelement.ecuseworldspace = threedtext.ecuseworldspace;
        newpropertyelement.eclineloop = threedtext.eclineloop;
        newpropertyelement.eccornervertices = threedtext.eccornervertices;
        newpropertyelement.ecendcapvertices = threedtext.ecendcapvertices;
        newpropertyelement.ecalignment = threedtext.ecalignment;
        newpropertyelement.ectexturemode = threedtext.ectexturemode;
        newpropertyelement.ecgld = threedtext.ecgld;
        newpropertyelement.ecsortinglayer = threedtext.ecsortinglayer;
        newpropertyelement.ecorderinlayer = threedtext.ecorderinlayer;
        newpropertyelement.eclightprobes = threedtext.eclightprobes;
        newpropertyelement.ecreflectionprobes = threedtext.ecreflectionprobes;

        newpropertyelement.ecmaterialname = threedtext.ecmaterialname;

        //Particle System
        newpropertyelement.ecpartsysemission = threedtext.ecpartsysemission;
        newpropertyelement.ecpartsysshape = threedtext.ecpartsysshape;
        newpropertyelement.ecpartsysvellife = threedtext.ecpartsysvellife;
        newpropertyelement.ecpartsyslimitveloverlife = threedtext.ecpartsyslimitveloverlife;
        newpropertyelement.ecpartsysinheritvel = threedtext.ecpartsysinheritvel;
        newpropertyelement.ecpartsysforceoverlife = threedtext.ecpartsysforceoverlife;
        newpropertyelement.ecpartsyscoloroverlife = threedtext.ecpartsyscoloroverlife;
        newpropertyelement.ecpartsyscolorbyspeed = threedtext.ecpartsyscolorbyspeed;
        newpropertyelement.ecpartsyssizebyspeed = threedtext.ecpartsyssizebyspeed;
        newpropertyelement.ecpartsysrotationoverlife = threedtext.ecpartsysrotationoverlife;
        newpropertyelement.ecpartsysrotationbyspeed = threedtext.ecpartsysrotationbyspeed;
        newpropertyelement.ecpartsysexternalforces = threedtext.ecpartsysexternalforces;
        newpropertyelement.ecpartsysnoise = threedtext.ecpartsysnoise;
        newpropertyelement.ecpartsyscollision = threedtext.ecpartsyscollision;
        newpropertyelement.ecpartsystriggers = threedtext.ecpartsystriggers;
        newpropertyelement.ecpartsyssubemitters = threedtext.ecpartsyssubemitters;
        newpropertyelement.ecpartsystexturesheetanim = threedtext.ecpartsystexturesheetanim;
        newpropertyelement.ecpartsyslights = threedtext.ecpartsyslights;
        newpropertyelement.ecpartsystrails = threedtext.ecpartsystrails;
        newpropertyelement.ecpartsyscustomdata = threedtext.ecpartsyscustomdata;
        newpropertyelement.ecpartsysrenderer = threedtext.ecpartsysrenderer;

        //Primitive
        newpropertyelement.ecmeshname = threedtext.ecmeshname;
        newpropertyelement.ecprimitivetype = threedtext.ecprimitivetype;
        newpropertyelement.eclightmapstatic = threedtext.eclightmapstatic;
        newpropertyelement.ecistrigger = threedtext.ecistrigger;
        newpropertyelement.eccenterx = threedtext.eccenterx;
        newpropertyelement.eccentery = threedtext.eccentery;
        newpropertyelement.eccenterz = threedtext.eccenterz;

        //Reflection Probe
        newpropertyelement.ecreflectionprobetype = threedtext.ecreflectionprobetype;
        newpropertyelement.ecimportance = threedtext.ecimportance;
        newpropertyelement.ecboxprojection = threedtext.ecboxprojection;
        newpropertyelement.ecboxsizex = threedtext.ecboxsizex;
        newpropertyelement.ecboxsizey = threedtext.ecboxsizey;
        newpropertyelement.ecboxsizez = threedtext.ecboxsizez;
        newpropertyelement.ecboxoffsetx = threedtext.ecboxoffsetx;
        newpropertyelement.ecboxoffsety = threedtext.ecboxoffsety;
        newpropertyelement.ecboxoffsetz = threedtext.ecboxoffsetz;
        newpropertyelement.eccubemapres = threedtext.eccubemapres;
        newpropertyelement.echdrcheck = threedtext.echdrcheck;
        newpropertyelement.ecshadowdistance = threedtext.ecshadowdistance;
        newpropertyelement.ecuseocclusionculling = threedtext.ecuseocclusionculling;

        //SpotLight
        newpropertyelement.ecrange = threedtext.ecrange;
        newpropertyelement.ecspotangel = threedtext.ecspotangel;

        //Sprite Mask
        newpropertyelement.ecalphacutoff = threedtext.ecalphacutoff;
        newpropertyelement.eccustomrange = threedtext.eccustomrange;
        newpropertyelement.ecspritesortpoint = threedtext.ecspritesortpoint;
        newpropertyelement.ecfrontsortlayer = threedtext.ecfrontsortlayer;
        newpropertyelement.ecfrontordrinlayer = threedtext.ecfrontordrinlayer;
        newpropertyelement.ecbacksortlayer = threedtext.ecbacksortlayer;
        newpropertyelement.ecbackordrinlayer = threedtext.ecbackordrinlayer;
        //newpropertyelement.ecspritesortpoint = threedtext.ecspritesortpoint;
        //Sprite Mask
   
        //TileMap
        newpropertyelement.ecafrate = threedtext.ecafrate;
        newpropertyelement.ectileanchor = threedtext.ectileanchor;
        newpropertyelement.ectileorentation = threedtext.ectileorentation;
        //Trail
        newpropertyelement.ectrailcastshadows = threedtext.ectrailcastshadows;
        newpropertyelement.ecdynamicoccludee = threedtext.ecdynamicoccludee;
        newpropertyelement.eclightparamaters = threedtext.eclightparamaters;
        newpropertyelement.ectrailtime = threedtext.ectrailtime;
        newpropertyelement.ecautodestruct = threedtext.ecautodestruct;
        newpropertyelement.ectrailemtting = threedtext.ectrailemtting;
        newpropertyelement.ectrailalignment = threedtext.ectrailalignment;
        newpropertyelement.ectrailtexturemode = threedtext.ectrailtexturemode;
        newpropertyelement.ectraillightdata = threedtext.ectraillightdata;


        //Tree
        newpropertyelement.ecprototypeindex = threedtext.ecprototypeindex;
    }
internal static class threedtext
{

    internal static bool name = true;
    internal static bool vector3 = true;
    internal static bool v3rotation = true;
    internal static bool v3scale = true;
    internal static bool radius = false;
    internal static bool text = true;
    internal static bool font = true;
    internal static bool fontsize = true;
    internal static bool ecfilelocation = false;
    internal static bool spritelocation = false;
    internal static bool spritename = false;
    internal static bool texturename = false;
    internal static bool texturelocation = false;
    internal static bool audioname = false;
    internal static bool audiolocation = false;
    internal static bool ecvector2 = false;
    internal static bool v2scale = false;
    internal static bool offsetX = false;
    internal static bool offsetY = false;
    internal static bool offsetZ = false;
    internal static bool depth = false;
    internal static bool terrainscale = false;
    internal static bool shadername = false;
    internal static bool shaderdropdown = false;
    internal static bool pixelper = false;
    internal static bool cellsize = false;
    internal static bool cellgap = false;
    internal static bool cellswizzle = false;
    internal static bool cliplocation = false;
    internal static bool windmode = false;
    internal static bool windmain = false;
    internal static bool pulsefreq = false;
    internal static bool pulsemag = false;
    internal static bool pulseturb = false;
    internal static bool fromraycast = false;
    internal static bool toraycast = false;
    internal static bool width = false;
    internal static bool height = false;
    internal static bool minwidth = false;
    internal static bool minheight = false;
    internal static bool maxwidth = false;
    internal static bool maxheight = false;
    internal static bool padding = false;
    internal static bool paddingx = false;
    internal static bool paddingy = false;
    internal static bool paddingz = false;
    internal static bool alpha = false;
    internal static bool rgbred = false;
    internal static bool rgbgreen = false;
    internal static bool rgbblue = false;
    internal static bool ecchildname = false;
    internal static bool ecchildindex = false;
    internal static bool parentthisobject = false;
    internal static bool ecparentindex = false;
    internal static bool ecdensity = false;
    internal static bool ecsaturation = false;

    //Audio reverb zone
    internal static bool maxdistance = false;
    internal static bool mindistance = false;
    internal static bool reverbpreset = false;
    internal static bool room = false;
    internal static bool roomhf = false;
    internal static bool roomlf = false;
    internal static bool decaytime = false;
    internal static bool decayhfratio = false;
    internal static bool reverbreflections = false;
    internal static bool reflectionsdelay = false;
    internal static bool reverb = false;
    internal static bool reverbdelay = false;
    internal static bool hfreference = false;
    internal static bool lfreference = false;
    internal static bool diffusion = false;
    internal static bool bgrgbred = false;
    internal static bool bgrgbgreen = false;
    internal static bool bgrgbblue = false;
    internal static bool density = false;

    //Camera
    internal static bool clearflags = false;
    internal static bool background = false;
    internal static bool projection = false;
    internal static bool fieldofview = false;
    internal static bool nearclipping = false;
    internal static bool farclipping = false;
    internal static bool viewportrectx = false;
    internal static bool viewportrecty = false;
    internal static bool viewportrectw = false;
    internal static bool viewportrecth = false;
    internal static bool renderingpath = false;
    internal static bool targettexture = false;
    internal static bool ecocclusioncolling = false;
    internal static bool ecallowhdr = false;
    internal static bool ecallowmsaa = false;
    internal static bool ecallowdynamicres = false;
    internal static bool targetdisply = false;

    //Directional Light
    internal static bool eccolorpanel = false;
    internal static bool lightmode = false;
    internal static bool indirectmultiplier = false;
    internal static bool ecintensity = false;
    internal static bool shadowtype = false;
    internal static bool eccookie = false;
    internal static bool eccookiesize = false;
    internal static bool ecshadowtype = false;
    internal static bool drawhalo = false;
    internal static bool eclightflare = false;
    internal static bool lightrendermode = false;
    internal static bool cullingmask = false;

    //Light Probe

    internal static bool showwireframe = false;
    internal static bool probeposx = false;
    internal static bool probeposy = false;
    internal static bool probeposz = false;
    internal static bool addprobebtn = false;
    internal static bool deleteprobebtn = false;
    internal static bool selectallprobesbtn = false;
    internal static bool duplicateprobesbtn = false;

    //Line Effect
    internal static bool eccastshadows = false;
    internal static bool ecrecieveshadows = false;
    internal static bool ecdynocc = false;
    internal static bool ecmotionvectors = false;
    internal static bool eclinepositions = false;
    internal static bool ecuseworldspace = false;
    internal static bool eclineloop = false;
    internal static bool eccornervertices = false;
    internal static bool ecendcapvertices = false;
    internal static bool ecalignment = false;
    internal static bool ectexturemode = false;
    internal static bool ecgld = false;
    internal static bool ecsortinglayer = false;
    internal static bool ecorderinlayer = false;
    internal static bool eclightprobes = false;
    internal static bool ecreflectionprobes = false;

    internal static bool ecmaterialname = false;

    //Particle System
    internal static bool ecpartsysemission = false;
    internal static bool ecpartsysshape = false;
    internal static bool ecpartsysvellife = false;
    internal static bool ecpartsyslimitveloverlife = false;
    internal static bool ecpartsysinheritvel = false;
    internal static bool ecpartsysforceoverlife = false;
    internal static bool ecpartsyscoloroverlife = false;
    internal static bool ecpartsyscolorbyspeed = false;
    internal static bool ecpartsyssizebyspeed = false;
    internal static bool ecpartsysrotationoverlife = false;
    internal static bool ecpartsysrotationbyspeed = false;
    internal static bool ecpartsysexternalforces = false;
    internal static bool ecpartsysnoise = false;
    internal static bool ecpartsyscollision = false;
    internal static bool ecpartsystriggers = false;
    internal static bool ecpartsyssubemitters = false;
    internal static bool ecpartsystexturesheetanim = false;
    internal static bool ecpartsyslights = false;
    internal static bool ecpartsystrails = false;
    internal static bool ecpartsyscustomdata = false;
    internal static bool ecpartsysrenderer = false;

    //Primitive
    internal static bool ecmeshname = false;
    internal static bool ecprimitivetype = false;
    internal static bool eclightmapstatic = false;
    internal static bool ecistrigger = false;
    internal static bool eccenterx = false;
    internal static bool eccentery = false;
    internal static bool eccenterz = false;

    //Reflection Probe
    internal static bool ecreflectionprobetype = false;
    internal static bool ecimportance = false;
    internal static bool ecboxprojection = false;
    internal static bool ecboxsizex = false;
    internal static bool ecboxsizey = false;
    internal static bool ecboxsizez = false;
    internal static bool ecboxoffsetx = false;
    internal static bool ecboxoffsety = false;
    internal static bool ecboxoffsetz = false;
    internal static bool eccubemapres = false;
    internal static bool echdrcheck = false;
    internal static bool ecshadowdistance = false;
    internal static bool ecuseocclusionculling = false;

    //Spot Light
    internal static bool ecrange = false;
    internal static bool ecspotangel = false;
    //Sprite
    internal static bool ecflipx = false;
    internal static bool ecflipy = false;
    internal static bool ecdrawmode = false;
    internal static bool ecmaskinteraction = false;
    //Sprite Mask
    internal static bool ecalphacutoff = false;
    internal static bool eccustomrange = false;
    internal static bool ecspritesortpoint = false;
    internal static bool ecfrontsortlayer = false;
    internal static bool ecfrontordrinlayer = false;
    internal static bool ecbacksortlayer = false;
    internal static bool ecbackordrinlayer = false;

    //TileMap
    internal static bool ecafrate = false;
    internal static bool ectileanchor = false;
    internal static bool ectileorentation = false;
    internal static bool ectmdetectchunkcullingbounds = false;
    //Trail
    internal static bool ectrailcastshadows = false;
    internal static bool ecdynamicoccludee = false;
    internal static bool eclightparamaters = false;
    internal static bool ectrailtime = false;
    internal static bool ecautodestruct = false;
    internal static bool ectrailemtting = false;
    internal static bool ectrailalignment = false;
    internal static bool ectrailtexturemode = false;
    internal static bool ectraillightdata = false;

    //Tree
    internal static bool ecprototypeindex = false;
}

The screen shot shows the result of the internal static class. true and false values are used to display listview items in the properties window.

You could make use of dictionary and could transfer all the variable values looping through each variable by calling it’s name in string format.

Another alternative is using reflection

PropertyInfo pi = threedtext.GetType().GetProperty("name");
newpropertyelement.setValueFor( "name"  ,  pi.GetValue(null, null) );

You can get all the fields in a string array and can loop each one in the above code.

Ok I think I understand what’s going on basically loop through a list of strings with all of the property names. name, vector3, v3rotation, v3scale, text ect

which will still be a long list but the length of code is crazy how small this just got.

Thanks for the {input}

Im not sure what to put in PropertyInfo.cs can u expand on what should go in that script?

It looks like the purpose of all these internal static classes is just to store all the properties that you want to set on some newly-created object? Can you create a prefab or template object somewhere to copy from, instead? That would save you a lot of work.

If you can’t…Do these internal static classes all have the same set of variables? If so, don’t define separate internal classes for each main class, just define a single class with all of those variables and then create instances of that class for everyone who needs one. (The instance can be stored in a private static variable if necessary.)

If you have THAT many variables inside of the class, it’s also pretty likely you would benefit from grouping some or all of them into collections of some kind. Maybe lists, maybe dictionaries, maybe something else. For organization, if nothing else–although it will also probably save you some coding somewhere. The ideal collection will depend on how you are using them, and possibly on how they are related to each other.

Ok I think im wrapping my head around this.

I have written this so far to create the dictionary with 2 values string,bool which is the name and state of the “element”

so from what I understand now that I have this dictionary setup I should be able to use a variation of what @VishwasGagrani has provided to set the bool values using a for loop.

@Antistone I do recall trying to create the classes while not using internal static variables but because I am loading prefabs from the resource they are required to be internal static. or at least that’s is what i can remember it has been a solid year since I touched this project. I think that was the issue I was dealing with.

public void CreatePropertiesDictionary() {
            PropertyInfo = new Dictionary<string,bool>();
            PropertyInfo.Add ("name", false);
            PropertyInfo.Add ("vector3", false);
            PropertyInfo.Add ("v3scale", false);
            PropertyInfo.Add ("text", false);
            PropertyInfo.Add ("font", false);
            PropertyInfo.Add ("fontsize", false);
            PropertyInfo.Add ("ecfilelocation", false);
            PropertyInfo.Add ("texturename", false);
            PropertyInfo.Add ("texturelocation", false);
            PropertyInfo.Add ("spritename", false);
            PropertyInfo.Add ("spritelocation", false);
            PropertyInfo.Add ("radius", false);
            PropertyInfo.Add ("ecvector2", false);
            PropertyInfo.Add ("v2scale", false);
            PropertyInfo.Add ("offsetX", false);
            PropertyInfo.Add ("offsetY", false);
            PropertyInfo.Add ("offsetZ", false);
            PropertyInfo.Add ("depth", false);
            PropertyInfo.Add ("terrainscale", false);
            PropertyInfo.Add ("shadername", false);
            PropertyInfo.Add ("shaderdropdown", false);
            PropertyInfo.Add ("pixelper", false);
            PropertyInfo.Add ("cellsize", false);
            PropertyInfo.Add ("cellgap", false);
            PropertyInfo.Add ("cellswizzle", false);
            PropertyInfo.Add ("cliplocation", false);
            PropertyInfo.Add ("windmode", false);
            PropertyInfo.Add ("windmain", false);
            PropertyInfo.Add ("pulsefreq", false);
            PropertyInfo.Add ("pulsemag", false);
            PropertyInfo.Add ("pulseturb", false);
            PropertyInfo.Add ("fromraycast", false);
            PropertyInfo.Add ("toraycast", false);
            PropertyInfo.Add ("width", false);
            PropertyInfo.Add ("height", false);
            PropertyInfo.Add ("minwidth", false);
            PropertyInfo.Add ("minheight", false);
            PropertyInfo.Add ("maxwidth", false);
            PropertyInfo.Add ("maxheight", false);
            PropertyInfo.Add ("padding", false);
            PropertyInfo.Add ("paddingx", false);
            PropertyInfo.Add ("paddingy", false);
            PropertyInfo.Add ("paddingz", false);
            PropertyInfo.Add ("rgbred", false);
            PropertyInfo.Add ("rgbgreen", false);
            PropertyInfo.Add ("rgbblue", false);
            PropertyInfo.Add ("echildname", false);
            PropertyInfo.Add ("ecchildindex", false);
            PropertyInfo.Add ("ecdensity", false);
            PropertyInfo.Add ("ecintensity", false);
            PropertyInfo.Add ("ecsaturation", false);
            PropertyInfo.Add ("maxdistance", false);
            PropertyInfo.Add ("mindistance", false);
            PropertyInfo.Add ("reverbpreset", false);
            PropertyInfo.Add ("room", false);
            PropertyInfo.Add ("roomhf", false);
            PropertyInfo.Add ("roomlf", false);
            PropertyInfo.Add ("decaytime", false);
            PropertyInfo.Add ("decayhfratio", false);
            PropertyInfo.Add ("reverbreflections", false);
            PropertyInfo.Add ("reverb", false);
            PropertyInfo.Add ("reverbdelay", false);
            PropertyInfo.Add ("hfreference", false);
            PropertyInfo.Add ("lfreference", false);
            PropertyInfo.Add ("bgrgbred", false);
            PropertyInfo.Add ("bgrgbgreen", false);
            PropertyInfo.Add ("bgrgbblue", false);
            PropertyInfo.Add ("density", false);
            PropertyInfo.Add ("clearflags", false);
            PropertyInfo.Add ("cullingmask", false);
            PropertyInfo.Add ("projection", false);
            PropertyInfo.Add ("fieldofview", false);
            PropertyInfo.Add ("nearclipping", false);
            PropertyInfo.Add ("farclipping", false);
            PropertyInfo.Add ("viewportrectx", false);
            PropertyInfo.Add ("viewportrecty", false);
            PropertyInfo.Add ("viewportrectw", false);
            PropertyInfo.Add ("viewportrecth", false);
            PropertyInfo.Add ("renderingpath", false);
            PropertyInfo.Add ("targettexture", false);
            PropertyInfo.Add ("ecallowhdr", false);
            PropertyInfo.Add ("ecallowmsaa", false);
            PropertyInfo.Add ("ecallowdynamicres", false);
            PropertyInfo.Add ("targetdisplay", false);
            PropertyInfo.Add ("indirectmultiplier", false);
            PropertyInfo.Add ("lightmode", false);
            PropertyInfo.Add ("shadowtype", false);
            PropertyInfo.Add ("eccookie", false);
            PropertyInfo.Add ("eccookiesize", false);
            PropertyInfo.Add ("ecshadowtype", false);
            PropertyInfo.Add ("drawhalo", false);
            PropertyInfo.Add ("eclightflare", false);
            PropertyInfo.Add ("lightrendermode", false);
            PropertyInfo.Add ("showwireframe", false);
            PropertyInfo.Add ("probeposx", false);
            PropertyInfo.Add ("probeposy", false);
            PropertyInfo.Add ("probeposz", false);
            PropertyInfo.Add ("addprobebtn", false);
            PropertyInfo.Add ("deleteprobebtn", false);
            PropertyInfo.Add ("selectallprobesbtn", false);
            PropertyInfo.Add ("duplicateprobesbtn", false);
            PropertyInfo.Add ("eccastshadows", false);
            PropertyInfo.Add ("ecrecieveshadows", false);
            PropertyInfo.Add ("ecdynocc", false);
            PropertyInfo.Add ("ecmotionvectors", false);
            PropertyInfo.Add ("eclinepositions", false);
            PropertyInfo.Add ("ecuseworldspace", false);
            PropertyInfo.Add ("eclineloop", false);
            PropertyInfo.Add ("eccornervertices", false);
            PropertyInfo.Add ("ecendcapvertices", false);
            PropertyInfo.Add ("ecalignment", false);
            PropertyInfo.Add ("ectexturemode", false);
            PropertyInfo.Add ("ecgld", false);
            PropertyInfo.Add ("ecsortinglayer", false);
            PropertyInfo.Add ("ecorderinlayer", false);
            PropertyInfo.Add ("eclightprobes", false);
            PropertyInfo.Add ("ecreflectionprobes", false);
            PropertyInfo.Add ("ecmaterialname", false);
            PropertyInfo.Add ("ecpartsysemission", false);
            PropertyInfo.Add ("ecpartsysshape", false);
            PropertyInfo.Add ("ecpartsysvellife", false);
            PropertyInfo.Add ("ecpartsyslimitveloverlife", false);
            PropertyInfo.Add ("ecpartsysinheritvel", false);
            PropertyInfo.Add ("ecpartsysforceoverlife", false);
            PropertyInfo.Add ("ecpartsyscoloroverlife", false);
            PropertyInfo.Add ("ecpartsyscolorbyspeed", false);
            PropertyInfo.Add ("ecpartsyssizebyspeed", false);
            PropertyInfo.Add ("ecpartsysrotationoverlife", false);
            PropertyInfo.Add ("ecpartsysrotationbyspeed", false);
            PropertyInfo.Add ("ecpartsysexternalforces", false);
            PropertyInfo.Add ("ecpartsysnoise", false);
            PropertyInfo.Add ("ecpartsyscollision", false);
            PropertyInfo.Add ("ecpartsystriggers", false);
            PropertyInfo.Add ("ecpartsyssubemitters", false);
            PropertyInfo.Add ("ecpartsystexturesheetanim", false);
            PropertyInfo.Add ("ecpartsyslights", false);
            PropertyInfo.Add ("ecpartsystrails", false);
            PropertyInfo.Add ("ecpartsyscustomdata", false);
            PropertyInfo.Add ("ecpartsysrenderer", false);
            PropertyInfo.Add ("ecmeshname", false);
            PropertyInfo.Add ("ecprimitivetype", false);
            PropertyInfo.Add ("eclightmapstatic", false);
            PropertyInfo.Add ("ecistrigger", false);
            PropertyInfo.Add ("eccenterx", false);
            PropertyInfo.Add ("eccentery", false);
            PropertyInfo.Add ("eccenterz", false);
            PropertyInfo.Add ("ecimportance", false);
            PropertyInfo.Add ("ecboxprojection", false);
            PropertyInfo.Add ("ecboxsizex", false);
            PropertyInfo.Add ("ecboxsizey", false);
            PropertyInfo.Add ("ecboxsizez", false);
            PropertyInfo.Add ("ecboxoffsetx", false);
            PropertyInfo.Add ("ecboxoffsety", false);
            PropertyInfo.Add ("ecboxoffsetz", false);
            PropertyInfo.Add ("eccubemapres", false);
            PropertyInfo.Add ("echdrcheck", false);
            PropertyInfo.Add ("ecshadowdistance", false);
            PropertyInfo.Add ("ecuseocclusionculling", false);
            PropertyInfo.Add ("ecrange", false);
            PropertyInfo.Add ("ecspotangel", false);
            PropertyInfo.Add ("ecalphacutoff", false);
            PropertyInfo.Add ("eccustomrange", false);
            PropertyInfo.Add ("ecspritesortpoint", false);
            PropertyInfo.Add ("ecfrontsortlayer", false);
            PropertyInfo.Add ("ecfrontordrinlayer", false);
            PropertyInfo.Add ("ecbacksortlayer", false);
            PropertyInfo.Add ("ecbackordrinlayer", false);
            PropertyInfo.Add ("ecafrate", false);
            PropertyInfo.Add ("ectileanchor", false);
            PropertyInfo.Add ("ectileorentation", false);
            PropertyInfo.Add ("ectrailcastshadows", false);
            PropertyInfo.Add ("ecdynamicoccludee", false);
            PropertyInfo.Add ("eclightparamaters", false);
            PropertyInfo.Add ("ectrailtime", false);
            PropertyInfo.Add ("ecautodestruct", false);
            PropertyInfo.Add ("ectrailemitting", false);
            PropertyInfo.Add ("ectrailalignment", false);
            PropertyInfo.Add ("ectrailtexturemode", false);
            PropertyInfo.Add ("ectraillightdata", false);
            PropertyInfo.Add ("ecprototypeindex", false);


        }

The link below is the whole script for the sake of showing all of it.

Im sure a lot more can be condensed. :confused:

Actually after I read about Reflection I think you should go for Dictionary. Reflection can solve your problem but it is slower. On the contrary dictionaries are faster

You will need two dictionary variables. One in threedtext, another in newpropertyelement.

//This is inside threedtext. A similar one needs to be defined inside newpropertyelement's class
Dictionary info<string,bool> = new Dictionary<string,bool >(){
   {"name", true},
   {"vector3", false },
   {"v3rotation",  true }
....
.....
};

once that is done you can loop inside method Set3DTextProperties

foreach ( Dictionary<string,bool> dict in info)
    {
       newpropertyelement.info[ dict.key ] = dict.value ;
     }

YESSSss. thats it. you just saved me so much time. I was just about to try and write the foreach loop in Set3DTextProperties()

clarification for threedtext is much apppreciated.

thanks everyone!! I can move forward once I get this implemented.

That’s not a thing. Using the special Resources folder doesn’t force you to make anything static. Prefabs actually can’t be static.

It sounds like you probably just don’t have much practice using classes. You might benefit from running through a few basic tutorials on how to use classes in C#. (Not in Unity specifically, just C# generally.)

I clearly know how to write classes. Could it be more Efficiently? yes
Im always reading and always learning.

Thank you again

One thing you can do is group commonly-associated properties into their own classes or structs.
For instance:
width, height, minWidth, minHeight, maxWidth, maxHeight, padding, paddingx, paddingy, paddingz.

All of these properties are related to how an object is positioned, so rather than placing them separately on your object, you could group them together in an ObjectPosition class, for instance, and then give your main object a reference to an ObjectPosition instance instead:

public class ObjectPosition {
   public float Width { get; set; }
   public float Height { get; set; }
   public float MinWidth { get; set; }
   public float MinHeight { get; set; }
   public float MaxWidth { get; set; }
   public float MaxHeight { get; set; }
   public float Padding { get; set; }
   public float PaddingX { get; set; }
   public float PaddingY { get; set; }
   public float PaddingZ { get; set; }
}

And heck, you could go further and separate width/height and padding into their own containers, then group them together in ObjectPosition:

public class ObjectPosition {
   public ObjectSize Size { get; set; }
   public ObjectPadding Padding { get; set; }
}

public class ObjectSize {
   public float Width { get; set; }
   public float MinWidth { get; set; }
   public float MaxWidth { get; set; }
   public float Height { get; set; }
   public float MinHeight { get; set; }
   public float MaxHeight { get; set; }
}

public class ObjectPadding {
   public float Padding { get; set; }
   public float PaddingX { get; set; }
   public float PaddingY { get; set; }
   public float PaddingZ { get; set; }
}

Either way, it allows you to go from this:

newpropertyelement.minwidth = threedtext.minwidth;
newpropertyelement.minheight = threedtext.minheight;
newpropertyelement.maxwidth = threedtext.maxwidth;
newpropertyelement.maxheight = threedtext.maxheight;
newpropertyelement.padding = threedtext.padding;
newpropertyelement.paddingx = threedtext.paddingx;
newpropertyelement.paddingy = threedtext.paddingy;
newpropertyelement.paddingz = threedtext.paddingz;

To something like this:

newpropertyelement.objectPosition = threedtext.objectPosition;

And then do the same for other commonly-associated properties.
Take advantage of objects in object-oriented programming to create separation of concerns.

If you want my honest two cents though, If I were returning to and old project of mine where I created a monolithic 9000-line long static class containing thousands of different properties, I would scrap it and redo it from scratch with a different architecture.

2 Likes