Skip to content

Commit d88785d

Browse files
committed
Fix texture deletion. v8.1.1 FINAL
1 parent cae9339 commit d88785d

4 files changed

Lines changed: 17 additions & 28 deletions

File tree

-512 Bytes
Binary file not shown.

RealSolarSystem/Readme_RSS.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ Pluto is represented by Vall
4646

4747
===========================
4848
Changelog
49+
v8.1.1
50+
*Fixed stupidity where I deleted textures after loading them.
51+
4952
v8.1
5053
*Completely revised loading system to use coroutines, added GUI. RSS will now load at the main menu, over a period of time to allow garbage collection to run. RAM usage should no longer spike as badly. Many thanks to stupid_chris for getting me set up with coroutines, and to Sarbian for help fixing some remaining issues. While loading may take slightly longer, you should be able to use more textures/parts, and you now get a handy GUI to track status.
5154
*Support calling textures from GameDatabase for the scaled space textures (SSColor, SSBump). This allows use combined with Sarbian's DDSLoader.

Source/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.8.1.0")]
36-
[assembly: AssemblyFileVersion("0.8.1.0")]
35+
[assembly: AssemblyVersion("0.8.1.1")]
36+
[assembly: AssemblyFileVersion("0.8.1.1")]

Source/RealSolarSystem.cs

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,10 +1554,9 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
15541554
{
15551555
guiExtra = "Color map";
15561556
//Texture2D map = GameDatabase.Instance.GetTexture(path, false);
1557-
Texture2D omap = null;
1558-
Texture map = null;
1559-
Texture[] textures = Resources.FindObjectsOfTypeAll(typeof(Texture)) as Texture[];
1560-
foreach (Texture tex in textures)
1557+
Texture2D map = null;
1558+
Texture2D[] textures = Resources.FindObjectsOfTypeAll(typeof(Texture2D)) as Texture2D[];
1559+
foreach (Texture2D tex in textures)
15611560
{
15621561
if (tex.name.Equals(path))
15631562
{
@@ -1570,16 +1569,17 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
15701569
yield return null;
15711570
if ((object)map == null)
15721571
{
1572+
print("RSS Loading local texture " + path);
15731573
localLoad = true;
15741574
success = false;
15751575
if (File.Exists(KSPUtil.ApplicationRootPath + path))
15761576
{
1577-
omap = new Texture2D(4, 4, replaceColor == 1 ? TextureFormat.RGB24 : TextureFormat.RGBA32, true);
1578-
omap.LoadImage(System.IO.File.ReadAllBytes(path));
1577+
map = new Texture2D(4, 4, replaceColor == 1 ? TextureFormat.RGB24 : TextureFormat.RGBA32, true);
1578+
map.LoadImage(System.IO.File.ReadAllBytes(path));
15791579
yield return null;
1580-
omap.Compress(true);
1581-
omap.Apply(true, true);
1582-
map = (Texture)omap;
1580+
map.Compress(true);
1581+
yield return null;
1582+
map.Apply(true, true);
15831583
yield return null;
15841584
success = true;
15851585
}
@@ -1600,14 +1600,6 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
16001600
oldColor = null;
16011601
yield return null;
16021602
}
1603-
if(t.gameObject.renderer.material.GetTexture("_MainTex") != map)
1604-
t.gameObject.renderer.material.SetTexture("_MainTex", map);
1605-
}
1606-
if (localLoad)
1607-
{
1608-
DestroyImmediate(map);
1609-
map = null;
1610-
yield return null;
16111603
}
16121604
}
16131605
yield return null;
@@ -1642,6 +1634,7 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
16421634
yield return null;
16431635
if (loadInfo.compressNormals)
16441636
map.Compress(true);
1637+
yield return null;
16451638
map.Apply(true, true);
16461639
yield return null;
16471640
}
@@ -1651,25 +1644,18 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
16511644
if (success)
16521645
{
16531646
Texture oldBump = t.gameObject.renderer.material.GetTexture("_BumpMap");
1647+
bool replacedOrig = false;
16541648
if (oldBump != null)
16551649
{
16561650
foreach (Material m in Resources.FindObjectsOfTypeAll(typeof(Material)))
16571651
{
1658-
if (m.GetTexture("_BumpMap") == oldBump)
1652+
if (m.GetTexture("_BumpMap") == oldBump || m == t.gameObject.renderer.material)
16591653
m.SetTexture("_BumpMap", map);
16601654
}
16611655
DestroyImmediate(oldBump);
16621656
oldBump = null;
16631657
yield return null;
16641658
}
1665-
if(t.gameObject.renderer.material.GetTexture("_BumpMap") != map)
1666-
t.gameObject.renderer.material.SetTexture("_BumpMap", map);
1667-
}
1668-
if (localLoad)
1669-
{
1670-
DestroyImmediate(map);
1671-
map = null;
1672-
yield return null;
16731659
}
16741660
yield return null;
16751661
guiExtra = "";

0 commit comments

Comments
 (0)