コード例 #1
0
ファイル: KSC.cs プロジェクト: spacefan/Kopernicus
                void Update()
                {
                    if (HighLogic.LoadedScene != GameScenes.SPACECENTER)
                    {
                        return;
                    }

                    KSC ksc = GetComponent <KSC>();

                    // Loop through all Materials and change their settings
                    try
                    {
                        foreach (Material material in Resources.FindObjectsOfTypeAll <Material>().Where(m => m.color.ToString() == new Color(0.640f, 0.728f, 0.171f, 0.729f).ToString()))
                        {
                            // Patch the texture
                            if (ksc.mainTexture != null)
                            {
                                material.mainTexture = ksc.mainTexture;
                            }

                            // Patch the color
                            if (ksc.color.HasValue)
                            {
                                material.color = ksc.color.Value;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.Log("[Kopernicus]: MaterialFixer: Exception " + e);
                    }
                    Destroy(this);
                }
コード例 #2
0
ファイル: KSC.cs プロジェクト: zambino12/Kopernicus
            void FixMaterials()
            {
                KSC ksc = KSC.Instance;

                if (ksc == null)
                {
                    return;
                }

                Material[] materials = Resources.FindObjectsOfTypeAll <Material>();

                int?n = materials?.Length;

                for (int i = 0; i < n; i++)
                {
                    Material material = materials[i];

                    if (material?.name == "ksc_exterior_terrain_grass_02")
                    {
                        if (ksc.groundMaterial != null)
                        {
                            material.shader = ksc.groundMaterial.shader;
                            material.CopyPropertiesFromMaterial(ksc.groundMaterial);
                        }
                    }

                    else

                    if (material?.name == "ksc_terrain_TX")
                    {
                        if (ksc.groundMaterial != null)
                        {
                            material.shader = ksc.groundMaterial.shader;
                            material.CopyPropertiesFromMaterial(ksc.groundMaterial);
                        }

                        if (ksc.editorGroundColor.HasValue)
                        {
                            material.color = ksc.editorGroundColor.Value;
                        }

                        if (ksc.editorGroundTex != null)
                        {
                            material.mainTexture = ksc.editorGroundTex;
                        }

                        if (ksc.editorGroundTexScale.HasValue)
                        {
                            material.mainTextureScale = ksc.editorGroundTexScale.Value;
                        }

                        if (ksc.editorGroundTexOffset.HasValue)
                        {
                            material.mainTextureOffset = ksc.editorGroundTexOffset.Value;
                        }
                    }
                }
            }
コード例 #3
0
ファイル: KSC.cs プロジェクト: MAJOR-T34/Kopernicus-1
        private void Awake()
        {
            if (Material == null)
            {
                Material = new GrassMaterial();
            }

            Instance = this;
        }
コード例 #4
0
ファイル: KSC.cs プロジェクト: MAJOR-T34/Kopernicus-1
        private void Start()
        {
            KSC ksc = KSC.Instance;

            if (!ksc)
            {
                return;
            }

            GameObject scenery  = GameObject.Find("VABscenery") ?? GameObject.Find("SPHscenery");
            Material   material = scenery?.GetChild("ksc_terrain")?.GetComponent <Renderer>()?.sharedMaterial;

            if (material == null)
            {
                return;
            }

            if (ksc.editorGroundColor.HasValue)
            {
                material.color = ksc.editorGroundColor.Value;
            }

            if (ksc.editorGroundTex)
            {
                material.mainTexture = ksc.editorGroundTex;
            }

            if (ksc.editorGroundTexScale.HasValue)
            {
                material.mainTextureScale = ksc.editorGroundTexScale.Value;
            }

            if (ksc.editorGroundTexOffset.HasValue)
            {
                material.mainTextureOffset = ksc.editorGroundTexOffset.Value;
            }
        }
コード例 #5
0
ファイル: KSC.cs プロジェクト: ysdavy/Kopernicus
        private void Start()
        {
            KSC ksc = KSC.Instance;

            if (!ksc)
            {
                return;
            }

            Material material = Resources.FindObjectsOfTypeAll <Material>()?.FirstOrDefault(m => m?.name == "ksc_terrain_TX");

            if (material == null)
            {
                return;
            }

            if (ksc.editorGroundColor.HasValue)
            {
                material.color = ksc.editorGroundColor.Value;
            }

            if (ksc.editorGroundTex)
            {
                material.mainTexture = ksc.editorGroundTex;
            }

            if (ksc.editorGroundTexScale.HasValue)
            {
                material.mainTextureScale = ksc.editorGroundTexScale.Value;
            }

            if (ksc.editorGroundTexOffset.HasValue)
            {
                material.mainTextureOffset = ksc.editorGroundTexOffset.Value;
            }
        }
コード例 #6
0
ファイル: KSC.cs プロジェクト: net-lisias-ksph/Kopernicus
            private void Update()
            {
                if (HighLogic.LoadedScene != GameScenes.SPACECENTER)
                {
                    return;
                }

                KSC ksc = GetComponent <KSC>();

                // Loop through all Materials and change their settings
                try
                {
                    Material[] materials = Resources.FindObjectsOfTypeAll <Material>();
                    Int32?     n         = materials?.Length;

                    for (Int32 i = 0; i < n; i++)
                    {
                        Material material = materials[i];

                        if (material.HasProperty("_Color") != true || material.color.ToString() != StockColor)
                        {
                            continue;
                        }

                        if (ksc.groundMaterial)
                        {
                            material.shader = ksc.groundMaterial.shader;
                            material.CopyPropertiesFromMaterial(ksc.groundMaterial);
                        }
                        else
                        {
                            // Remember this material
                            ksc.groundMaterial = material;

                            // Patch the texture
                            if (ksc.mainTexture)
                            {
                                material.mainTexture = ksc.mainTexture;
                            }
                            else
                            {
                                ksc.mainTexture = material.mainTexture as Texture2D;
                            }

                            // Patch the color
                            if (ksc.color.HasValue)
                            {
                                material.color = ksc.color.Value;
                            }
                            else
                            {
                                ksc.color = material.color;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.Log("[Kopernicus]: MaterialFixer: Exception " + e);
                }

                Destroy(this);
            }
コード例 #7
0
ファイル: KSC.cs プロジェクト: net-lisias-ksph/Kopernicus
 private void Awake()
 {
     Instance = this;
 }
コード例 #8
0
ファイル: KSC.cs プロジェクト: zambino12/Kopernicus
 void Awake()
 {
     Instance = this;
 }