Procházet zdrojové kódy

Fix

Le bloc de preview ne saccade plus
shader
Figg před 4 roky
rodič
revize
0879aeb52a

+ 5
- 14
FreeCam/Assets/BlockSpawner.cs Zobrazit soubor

@@ -26,18 +26,10 @@ public class BlockSpawner : MonoBehaviour
26 26
 
27 27
     private bool _isPreview = false;
28 28
 
29
-
30
-    public void Update()
31
-    {
32
-        if (_blockInstance == null) return;
33
-
34
-        _blockInstance.transform.position = transform.position + transform.forward * spawnDistance;
35
-        _blockInstance.transform.rotation = transform.rotation;
36
-    }
37
-
38 29
     public void OnPlaceBlock()
39 30
     {
40 31
         if (!_isPreview) return;
32
+        _blockInstance.transform.SetParent(null);
41 33
         _blockInstance = null;
42 34
         DisablePreviewMode();
43 35
     }
@@ -54,16 +46,15 @@ public class BlockSpawner : MonoBehaviour
54 46
     {
55 47
         if (_blockToPlace == null) return;
56 48
 
57
-        Vector3 pos = transform.position + transform.forward * spawnDistance;
58
-        Quaternion rot = transform.rotation;
59
-        _blockInstance = Instantiate(_blockToPlace, pos, rot);
49
+        Vector3 spawnPos = Vector3.forward * spawnDistance;
50
+        _blockInstance = Instantiate(_blockToPlace, spawnPos, Quaternion.identity);
51
+        _blockInstance.transform.SetParent(this.transform, false);
60 52
         _isPreview = true;
61 53
     }
62 54
 
63 55
     private void DisablePreviewMode()
64 56
     {
65
-        Destroy(_blockInstance);
66
-        Debug.Log("disabled");
57
+        if (_blockInstance != null) Destroy(_blockInstance);
67 58
         _isPreview = false;
68 59
     }
69 60
 }

+ 1
- 1
FreeCam/Assets/Scenes/SampleScene.unity Zobrazit soubor

@@ -687,6 +687,6 @@ PrefabInstance:
687 687
     - target: {fileID: 6193258497320629589, guid: 37333bbc22b455449a05fcf8aa6b9a8f, type: 3}
688 688
       propertyPath: _blockToPlace
689 689
       value: 
690
-      objectReference: {fileID: 0}
690
+      objectReference: {fileID: 3300812737117657924, guid: 7b30a4c90d614f747872471cf43b8e56, type: 3}
691 691
     m_RemovedComponents: []
692 692
   m_SourcePrefab: {fileID: 100100000, guid: 37333bbc22b455449a05fcf8aa6b9a8f, type: 3}

Načítá se…
Zrušit
Uložit