Ejemplo n.º 1
0
        private TextureSet getSet(PartVariant variant)
        {
            string     setName = variant.GetExtraInfoValue("textureSet");
            TextureSet set     = null;

            if (!string.IsNullOrEmpty(setName))
            {
                set            = TexturesUnlimitedLoader.getTextureSet(setName);
                textureSet     = setName;
                modelShaderSet = string.Empty;
                return(set);
            }
            setName = variant.GetExtraInfoValue("modelShader");
            if (!string.IsNullOrEmpty(setName))
            {
                set            = TexturesUnlimitedLoader.getModelShaderTextureSet(setName);
                modelShaderSet = setName;
                textureSet     = string.Empty;
                return(set);
            }
            //if nothing found, clear out references
            if (TexturesUnlimitedLoader.logErrors || TexturesUnlimitedLoader.logAll)
            {
                MonoBehaviour.print("Could not load texture set for part variant: " + variant?.Name + " for part: " + part.name);
            }
            modelShaderSet = textureSet = string.Empty;
            return(null);
        }
Ejemplo n.º 2
0
        //really, could probably just move this back to the base class, possibly with a config bool for toggling enable of the secondary updates
        public void Start()
        {
            TextureSet ts = TexturesUnlimitedLoader.getTextureSet(textureSet);

            if (ts != null)
            {
                //apply the textur set to the base model, use set-specified mask colors (does not support user recoloring)
                ts.enable(part.transform.FindRecursive("model"), ts.maskColors);
                TextureSetMaterialData tsmd = ts.textureData[materialIndex];
                //adjust the already existing fairing materials and fairing panels
                ModuleProceduralFairing mpf = part.GetComponent <ModuleProceduralFairing>();
                if (mpf != null)
                {
                    if (mpf.FairingMaterial != null && mpf.FairingConeMaterial != null)
                    {
                        tsmd.apply(mpf.FairingMaterial);
                        tsmd.apply(mpf.FairingConeMaterial);
                    }
                    if (mpf.Panels != null && mpf.Panels.Count > 0)//cones are included in regular panels
                    {
                        int len = mpf.Panels.Count;
                        for (int i = 0; i < len; i++)
                        {
                            tsmd.apply(mpf.Panels[i].mat);
                            tsmd.apply(mpf.Panels[i].go.GetComponent <Renderer>().material);
                        }
                    }
                }
            }
            //prev shader-only code...
            //Shader shader = TexturesUnlimitedLoader.getShader(this.shader);
            //if (mpf != null && shader != null && mpf.FairingMaterial != null)
            //{
            //    mpf.FairingMaterial.shader = shader;
            //    if (mpf.FairingConeMaterial != null) { mpf.FairingConeMaterial.shader = shader; }
            //    MonoBehaviour.print("Adjusted MPF materials!");
            //    if (mpf.Panels != null && mpf.Panels.Count > 0)//cones are included in regular panels
            //    {
            //        int len = mpf.Panels.Count;
            //        for (int i = 0; i < len; i++)
            //        {
            //            mpf.Panels[i].mat.shader = shader;
            //            mpf.Panels[i].go.GetComponent<Renderer>().material.shader = shader;
            //        }
            //    }
            //}
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Public utility method to retrieve just the display titles of the texture sets from the input collection of nodes.
        /// </summary>
        /// <param name="nodes"></param>
        /// <returns></returns>
        public static string[] getTextureSetTitles(ConfigNode[] nodes)
        {
            List <string> names = new List <string>();
            string        name;
            TextureSet    set;
            int           len = nodes.Length;

            for (int i = 0; i < len; i++)
            {
                name = nodes[i].GetStringValue("name");
                set  = TexturesUnlimitedLoader.getTextureSet(name);
                if (set != null)
                {
                    names.Add(set.title);
                }
            }
            return(names.ToArray());
        }
Ejemplo n.º 4
0
        private TextureSet getSet()
        {
            TextureSet set = null;

            if (!string.IsNullOrEmpty(textureSet) && (set = TexturesUnlimitedLoader.getTextureSet(textureSet)) != null)
            {
                modelShaderSet = string.Empty;
                return(set);
            }
            else if (!string.IsNullOrEmpty(modelShaderSet) && (set = TexturesUnlimitedLoader.getModelShaderTextureSet(modelShaderSet)) != null)
            {
                textureSet = string.Empty;
                return(set);
            }
            else if ((set = getSet(part.baseVariant)) != null)
            {
                return(set);
            }
            //if nothing found, clear out references
            modelShaderSet = textureSet = string.Empty;
            return(null);
        }
Ejemplo n.º 5
0
 public TextureSet getSectionTexture(string name)
 {
     return(string.IsNullOrEmpty(textureSet)? TexturesUnlimitedLoader.getModelShaderTextureSet(modelShaderSet) : TexturesUnlimitedLoader.getTextureSet(textureSet));
 }