mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Fix OnDestroy not being called
This commit is contained in:
parent
2cca6c37bb
commit
dfdf280564
@ -14,6 +14,10 @@ All notable changes to this project will be documented in this file
|
||||
|
||||
- Updated bundled Shabby to 0.3.0. Does not affect CKAN users
|
||||
|
||||
### Fixed
|
||||
|
||||
- Reverted some changes from last version that were causing issues on launch
|
||||
|
||||
|
||||
## 0.2.11 - 2022-10-30
|
||||
|
||||
|
@ -122,8 +122,7 @@ namespace ConformalDecals {
|
||||
|
||||
if (materialProperties == null) {
|
||||
materialProperties = ScriptableObject.CreateInstance<MaterialPropertyCollection>();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
materialProperties = ScriptableObject.Instantiate(materialProperties);
|
||||
}
|
||||
}
|
||||
@ -153,14 +152,12 @@ namespace ConformalDecals {
|
||||
if (backRenderer == null) {
|
||||
this.LogError($"Specified decalBack transform {decalBack} has no renderer attached! Setting updateBackScale to false.");
|
||||
updateBackScale = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
backMaterial = backRenderer.material;
|
||||
if (backMaterial == null) {
|
||||
this.LogError($"Specified decalBack transform {decalBack} has a renderer but no material! Setting updateBackScale to false.");
|
||||
updateBackScale = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (backTextureBaseScale == default) backTextureBaseScale = backMaterial.GetTextureScale(PropertyIDs._MainTex);
|
||||
}
|
||||
}
|
||||
@ -201,12 +198,10 @@ namespace ConformalDecals {
|
||||
|
||||
if (tileRect.x >= 0) {
|
||||
materialProperties.UpdateTile(tileRect);
|
||||
}
|
||||
else if (tileIndex >= 0) {
|
||||
} else if (tileIndex >= 0) {
|
||||
materialProperties.UpdateTile(tileIndex, tileSize);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
this.LogException("Exception parsing partmodule", e);
|
||||
}
|
||||
|
||||
@ -222,8 +217,7 @@ namespace ConformalDecals {
|
||||
|
||||
if (HighLogic.LoadedSceneIsGame) {
|
||||
UpdateScale();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
scale = defaultScale;
|
||||
depth = defaultDepth;
|
||||
opacity = defaultOpacity;
|
||||
@ -261,8 +255,7 @@ namespace ConformalDecals {
|
||||
// set initial attachment state
|
||||
if (part.parent == null) {
|
||||
OnDetach();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
OnAttach();
|
||||
}
|
||||
}
|
||||
@ -283,7 +276,7 @@ namespace ConformalDecals {
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDestroy() {
|
||||
public virtual void OnDestroy() {
|
||||
// remove GameEvents
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
GameEvents.onEditorPartEvent.Remove(OnEditorEvent);
|
||||
@ -440,11 +433,13 @@ namespace ConformalDecals {
|
||||
|
||||
// update projection
|
||||
foreach (var target in _targets) {
|
||||
if (target != null)
|
||||
if (target == null) {
|
||||
_targets.Remove(target);
|
||||
} else {
|
||||
target.Project(_orthoMatrix, decalProjectorTransform, _boundsRenderer.bounds, useBaseNormal);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// rescale preview model
|
||||
decalModelTransform.localScale = new Vector3(size.x, size.y, (size.x + size.y) / 2);
|
||||
|
||||
@ -472,8 +467,7 @@ namespace ConformalDecals {
|
||||
protected void UpdateTargets() {
|
||||
if (_targets == null) {
|
||||
_targets = new List<ProjectionTarget>();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
_targets.Clear();
|
||||
}
|
||||
|
||||
@ -578,8 +572,11 @@ namespace ConformalDecals {
|
||||
|
||||
// render on each target object
|
||||
foreach (var target in _targets) {
|
||||
if (target != null)
|
||||
if (target == null) {
|
||||
_targets.Remove(target);
|
||||
} else {
|
||||
target.Render(_decalMaterial, part.mpb, camera);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,12 +48,14 @@ namespace ConformalDecals {
|
||||
UpdateFlag();
|
||||
}
|
||||
|
||||
public void OnDestroy() {
|
||||
public virtual void OnDestroy() {
|
||||
if (HighLogic.LoadedSceneIsEditor) {
|
||||
// Unregister flag change event
|
||||
GameEvents.onMissionFlagSelect.Remove(OnEditorFlagSelected);
|
||||
}
|
||||
}
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
[KSPEvent(guiActive = false, guiActiveEditor = true, guiName = "#LOC_ConformalDecals_gui-select-flag")]
|
||||
public void SelectFlag() {
|
||||
@ -104,11 +106,10 @@ namespace ConformalDecals {
|
||||
// get the decal material property for the decal texture
|
||||
var textureProperty = materialProperties.AddOrGetTextureProperty("_Decal", true);
|
||||
|
||||
if(useCustomFlag) {
|
||||
if (useCustomFlag) {
|
||||
// set the texture to the custom flag
|
||||
textureProperty.TextureUrl = flagUrl;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// set the texture to the mission flag
|
||||
textureProperty.TextureUrl = MissionFlagUrl;
|
||||
}
|
||||
|
@ -227,6 +227,8 @@ namespace ConformalDecals {
|
||||
if (_textEntryController != null) _textEntryController.Close();
|
||||
if (_fillColorPickerController != null) _fillColorPickerController.Close();
|
||||
if (_outlineColorPickerController != null) _outlineColorPickerController.Close();
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
protected override void OnDetach() {
|
||||
|
Loading…
Reference in New Issue
Block a user