private static void SetupFootprintPrefab()
            {
                footprintPrefab       = new GameObject("KerbalEVAFootprint");
                footprintPrefab.layer = GameLayers.LOCAL_SPACE;
                footprintPrefab.SetActive(false);

                MeshFilter   mf = footprintPrefab.AddComponent <MeshFilter>();
                MeshRenderer mr = footprintPrefab.AddComponent <MeshRenderer>();

                mf.mesh = new Quad(0.15f, 0.3f, true);

                Material        material      = new Material(ShaderLoader.GetShader("KopernicusExpansion/Footprint"));
                Texture2DParser footprintMask = new Texture2DParser();

                footprintMask.SetFromString("KopernicusExpansion/Textures/KerbalEVAFootprintMask");
                material.SetTexture("_MainTex", footprintMask);
                material.SetFloat("_Opacity", 0.8f);
                material.SetColor("_Color", Color.black);
                mr.material          = material;
                mr.shadowCastingMode = ShadowCastingMode.Off;
                footprintPrefab.AddComponent <EVAFootprint>();
                Debug.Log("[KopernicusExpansion] Footprint prefab created");
            }
Example #2
0
                void IParserEventSubscriber.PostApply(ConfigNode node)
                {
                    if (node.HasNode("Watermain"))
                    {
                        // Parse the watermain textures
                        ConfigNode watermain = node.GetNode("Watermain");

                        // Set the Watermain length
                        _mod.waterMainLength = watermain.values.Count;

                        // If the count doesn't matches, recreate the array
                        if (_mod.watermain.Length != _mod.waterMainLength)
                        {
                            _mod.watermain = new Texture2D[(int)_mod.waterMainLength];
                        }

                        // Load the textures
                        int i = 0;
                        foreach (string s in watermain.GetValuesStartsWith("waterTex-"))
                        {
                            Texture2DParser texParser = new Texture2DParser();
                            texParser.SetFromString(s);
                            _mod.watermain[i] = texParser.value;
                            i++;
                        }
                    }
                }
Example #3
0
        // Post apply event
        void IParserEventSubscriber.PostApply(ConfigNode node)
        {
            Logger.Active.Log("============= Scaled Version Dump ===================");
            Utility.GameObjectWalk(Value.scaledBody);
            Logger.Active.Log("===========================================");

            // If we are a star, we need to generate the coronas
            if (Type.Value == BodyType.Star)
            {
                // Restore backed up coronas if no custom ones were specified
                if (!Coronas.Any())
                {
                    foreach (SunCoronas corona in Utility.Deactivator.GetComponentsInChildren <SunCoronas>(true)
                             .Where(c => c.transform.parent == Utility.Deactivator))
                    {
                        corona.transform.parent = Value.scaledBody.transform;
                    }
                }
                else
                {
                    foreach (SunCoronas corona in Utility.Deactivator.GetComponentsInChildren <SunCoronas>(true)
                             .Where(c => c.transform.parent == Utility.Deactivator))
                    {
                        corona.transform.parent = null;
                        Object.Destroy(corona.gameObject);
                    }
                }
            }

            // If we use OnDemand, we need to delete the original textures and reload them
            if (Type.Value != BodyType.Star && OnDemandTextures != null)
            {
                if (OnDemandStorage.UseOnDemand)
                {
                    ScaledSpaceOnDemand onDemand = Value.scaledBody.AddComponent <ScaledSpaceOnDemand>();
                    onDemand.texture = OnDemandTextures.Texture;
                    onDemand.normals = OnDemandTextures.Normals;

                    // Delete the original scaled space textures
                    if (OnDemandTextures.Texture != null)
                    {
                        Texture2D texture = new Texture2D(1, 1);
                        texture.Apply();
                        Material.SetTexture(MainTex, texture);
                    }

                    if (OnDemandTextures.Normals != null)
                    {
                        Texture2D texture = new Texture2D(1, 1);
                        texture.Apply();
                        Material.SetTexture(BumpMap, texture);
                    }
                }
                else
                {
                    // If OD isn't enabled, load the textures, assign them and don't care anymore
                    Texture2DParser parser = new Texture2DParser();

                    if (OnDemandTextures.Texture != null)
                    {
                        parser.SetFromString(OnDemandTextures.Texture);
                        Material.SetTexture(MainTex, parser);
                    }

                    if (OnDemandTextures.Normals != null)
                    {
                        parser.SetFromString(OnDemandTextures.Normals);
                        Material.SetTexture(BumpMap, parser);
                    }
                }
            }

            // Event
            Events.OnScaledVersionLoaderPostApply.Fire(this, node);
        }