Merge Explode + unexplodeButton, make animation

This commit is contained in:
Tim
2025-06-30 23:18:09 +02:00
parent d7959b104d
commit 513ba14147
8 changed files with 52 additions and 425 deletions

View File

@@ -443,142 +443,6 @@ Transform:
- {fileID: 1227652227}
m_Father: {fileID: 434687814}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &14989656
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 14989657}
- component: {fileID: 14989659}
- component: {fileID: 14989658}
m_Layer: 0
m_Name: ReturnButtonText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &14989657
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 14989656}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 444853961}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &14989658
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 14989656}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Unexplode
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 24
m_fontSizeBase: 24
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &14989659
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 14989656}
m_CullTransparentMesh: 1
--- !u!1 &29009377
GameObject:
m_ObjectHideFlags: 0
@@ -6373,165 +6237,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
_facing: 0
_doubleSided: 0
--- !u!1 &444853960
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 444853961}
- component: {fileID: 444853966}
- component: {fileID: 444853965}
- component: {fileID: 444853964}
- component: {fileID: 444853963}
- component: {fileID: 444853962}
m_Layer: 0
m_Name: UnExplode
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &444853961
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 444853960}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 14989657}
m_Father: {fileID: 525196406}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -3, y: 0}
m_SizeDelta: {x: 180, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &444853962
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 444853960}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 148fd3ba1bc1c7745bd89a67b61c8834, type: 3}
m_Name:
m_EditorClassIdentifier:
go: {fileID: 645201570}
explodeBUtton: {fileID: 465093186}
mm: {fileID: 1519836175}
--- !u!114 &444853963
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 444853960}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.21960786, g: 0.21960786, b: 0.21960786, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &444853964
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 444853960}
m_CullTransparentMesh: 1
--- !u!65 &444853965
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 444853960}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &444853966
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 444853960}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 444853963}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!1 &456915309
GameObject:
m_ObjectHideFlags: 0
@@ -6634,7 +6339,7 @@ GameObject:
- component: {fileID: 465093188}
- component: {fileID: 465093187}
m_Layer: 0
m_Name: Explode
m_Name: ExplodeButton
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -6653,8 +6358,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
mm: {fileID: 1519836175}
go: {fileID: 645201570}
unexplodeButton: {fileID: 444853960}
baseModel: {fileID: 645201570}
text: {fileID: 1785144091}
--- !u!114 &465093188
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -7752,7 +7457,6 @@ RectTransform:
- {fileID: 1612592526}
- {fileID: 576843183}
- {fileID: 465093193}
- {fileID: 444853961}
- {fileID: 1334436260}
- {fileID: 806803887}
- {fileID: 1124732204}
@@ -8103,7 +7807,7 @@ MonoBehaviour:
_lutWeight: 1
_flipLutY: 1
serializedSurfaceGeometry: []
textureOpacity_: 1
textureOpacity_: 0.557
edgeRenderingEnabled_: 0
edgeColor_: {r: 1, g: 1, b: 1, a: 1}
colorMapType: 0
@@ -8624,10 +8328,10 @@ MonoBehaviour:
m_EditorClassIdentifier:
bms: {fileID: 624025131}
mm: {fileID: 1519836175}
buttonCanvas: {fileID: 525196400}
buttonCanvas: {fileID: 0}
explodeButton: {fileID: 465093186}
unexplodeButton: {fileID: 444853960}
cmsCanvas: {fileID: 1509914124}
unexplodeButton: {fileID: 0}
cmsCanvas: {fileID: 0}
--- !u!224 &576843183
RectTransform:
m_ObjectHideFlags: 0
@@ -9229,7 +8933,6 @@ MonoBehaviour:
buttonPrefab: {fileID: 580659756}
portSelector: {fileID: 1494770816}
modelManager: {fileID: 1519836175}
unexplodeButton: {fileID: 444853960}
uiButtonsCanvas: {fileID: 525196400}
cmsCanvas: {fileID: 1509914124}
--- !u!1 &628967020
@@ -11681,7 +11384,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1b59dae33d214a62aa135792503fcac9, type: 3}
m_Name:
m_EditorClassIdentifier:
passthroughLayer: {fileID: 0}
passthroughLayer: {fileID: 548570668}
--- !u!1 &810018954
GameObject:
m_ObjectHideFlags: 0
@@ -21288,7 +20991,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
baseModelGO: {fileID: 645201570}
baseModelSelector: {fileID: 624025131}
childPositions: []
--- !u!4 &1519836176
Transform:
m_ObjectHideFlags: 0
@@ -21641,7 +21343,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c488bedd8c9cbf4448fef2edf45f0788, type: 3}
m_Name:
m_EditorClassIdentifier:
cms: {fileID: 89481405}
cms: {fileID: 0}
marker: {fileID: 0}
--- !u!222 &1541654566
CanvasRenderer:
@@ -22420,7 +22122,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1591058970}
m_Enabled: 0
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
m_Name:
@@ -22481,7 +22183,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1591058970}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2518c50cb3fc6a6458d4b743c2f69c7d, type: 3}
m_Name:
@@ -25611,7 +25313,7 @@ GameObject:
- component: {fileID: 1785144092}
- component: {fileID: 1785144091}
m_Layer: 0
m_Name: ReturnButtonText
m_Name: ExplodeButtonText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

View File

@@ -20,7 +20,6 @@ public class ModelManager : MonoBehaviour
get { return baseModelGO.GetComponent<BaseModelBehaviour>(); }
}
public BaseModelSelector baseModelSelector;
public List<Vector3> childPositions = new List<Vector3>();
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()

View File

@@ -1,102 +1,63 @@
using System;
using System.Collections.Generic;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
public class ExplodeModel : MonoBehaviour
{
public ModelManager mm;
public GameObject go;
public GameObject unexplodeButton;
public GameObject baseModel;
public TextMeshProUGUI text;
private float y;
private float z;
private float x;
List<Vector3> goalPos = new List<Vector3>();
List<Vector3> initialPos = new List<Vector3>();
static readonly int finalTick = 60 * 2; // 60fps * 2sek
bool explode = false;
int tick = finalTick + 1;
void Start()
{
GetComponent<Button>().onClick.AddListener(Explode);
}
private void Explode()
{
y = 0;
z = 0;
x = 0;
mm.childPositions.Clear();
foreach (Transform child in go.transform)
{
mm.childPositions.Add(child.localPosition);
var childModelBehaviour = child.GetComponent<ChildModelBehaviour>();
Port port = mm.GetPortForChildModel(childModelBehaviour.ChildModel);
if (port.ExplodeDirection != Vector3.zero)
{
Vector3 richtung = Richtung(port.ExplodeDirection);
Debug.Log("Richtung Pos" + richtung*10);
child.localPosition += richtung*10;
}
}
gameObject.SetActive(false);
unexplodeButton.SetActive(true);
}
private Vector3 Richtung(Vector3 direction)
void Update()
{
if (tick <= finalTick)
{
float dx = direction.x;
float dy = direction.y;
float dz = direction.z;
Debug.Log("Vector Richtung "+direction);
if (dx != 0)
{
if (dx > 0)
{
this.x++;
return new Vector3(0f + x, 0f, 0f);
}
else if (dx < 0)
{
this.x++;
return new Vector3(0f - x, 0f, 0f);
}
}
else if (dy != 0)
{
if (dy > 0)
{
y = 4;
return new Vector3(0f, 0f + y, 0f);
}
else if (dy < 0)
{
y = 4;
Debug.Log("Y Pos" + y);
var vector = new Vector3(0f, 0f - y, 0f);
Debug.Log("Vector Richtung " + vector);
return vector;
}
}
else if (dz != 0)
{
if (dz > 0)
{
z+=5;
return new Vector3(0f, 0f, 0f + z);
}
else if (dz < 0)
{
z+=5;
return new Vector3(0f, 0f, 0f - z);
if(explode)
for (int i = 0; i < baseModel.transform.childCount; i++)
baseModel.transform.GetChild(i).transform.localPosition = MathUtil.EaseBoth(initialPos[i], goalPos[i], (tick + 0f)/finalTick); //0f for floating point div
else
for (int i = 0; i < baseModel.transform.childCount; i++)
baseModel.transform.GetChild(i).transform.localPosition = MathUtil.EaseBoth(goalPos[i], initialPos[i], (tick + 0f)/finalTick); //0f for floating point div
tick++;
}
}
return default;
void Explode()
{
if (!explode) // before switching to true
{
initialPos.Clear();
goalPos.Clear();
foreach (Transform child in baseModel.transform)
{
ChildModel cm = child.GetComponent<ChildModelBehaviour>().ChildModel;
Port port = mm.GetPortForChildModel(cm);
initialPos.Add(child.localPosition);
goalPos.Add(child.localPosition + port.ExplodeDirection);
}
}
text.text = explode ? "Explode" : "Unexplode";
explode = !explode;
tick = 0;
}
}

View File

@@ -1,27 +0,0 @@
using UnityEngine;
using UnityEngine.UI;
public class UnExplode : MonoBehaviour
{
public GameObject go;
public GameObject explodeBUtton;
public ModelManager mm;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
GetComponent<Button>().onClick.AddListener(unexplode);
}
private void unexplode()
{
explodeBUtton.SetActive(true);
gameObject.SetActive(false);
int i = 0;
foreach (Transform child in go.transform)
{
child.localPosition = mm.childPositions[i];
i++;
}
}
}

View File

@@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 148fd3ba1bc1c7745bd89a67b61c8834

View File

@@ -10,8 +10,6 @@ public class BaseModelSelector : MonoBehaviour
public GameObject buttonPrefab;
public PortSelector portSelector;
public ModelManager modelManager;
public GameObject unexplodeButton;
public GameObject uiButtonsCanvas;
public GameObject cmsCanvas;
@@ -71,15 +69,9 @@ public class BaseModelSelector : MonoBehaviour
}
gameObject.SetActive(false);
if (unexplodeButton == null)
{
Debug.LogError("UnexplodeButton is null!");
}
unexplodeButton.SetActive(false);
if (cmsCanvas == null)
{
Debug.LogError("UnexplodeButton is null!");
Debug.LogError("CMS Canvas is null!");
}
cmsCanvas.SetActive(true);
}

View File

@@ -1,6 +1,8 @@
using System;
using UnityEngine;
// THIS IS TAKEN OUT OF A MATH LIBRARY
public static class MathUtil
{
public static float EaseIn(float startNum, float endNum, float pct)

View File

@@ -75,7 +75,7 @@ QualitySettings:
globalTextureMipmapLimit: 0
textureMipmapLimitSettings: []
anisotropicTextures: 1
antiAliasing: 2
antiAliasing: 4
softParticles: 0
softVegetation: 1
realtimeReflectionProbes: 0