Browse Source

还原旧的

wuyu 1 năm trước cách đây
mục cha
commit
7b4c3ed162

+ 1 - 1
Assembly-CSharp-Editor.csproj

@@ -46,12 +46,12 @@
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetUI/LeanTween/Editor/LeanTweenDocumentationEditor.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/Paper Fold/Scripts/Editor/FoldingEditor.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetUI/UIGradient/Editor/UIGradientEditor.cs" />
+     <Compile Include="Assets/Tools/Editor/CleanTools/CleanTools.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetUI/Scripts/Editor/UIManagerEditor.cs" />
      <Compile Include="Assets/Editor/TexturesPostprocessor.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/DecalToTexture/Scripts/Editor/DecalMasterEditor.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/GDPR Panel/_Scripts/Editor/GDPREditor.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetUI/Scripts/Editor/Tools.cs" />
-     <Compile Include="Assets/Tools/Editor/CleanTools/CleanTools.cs" />
      <None Include="Assets/_Packages/PaperFoldAsset/ExternalDependencyManager/Editor/GoogleRegistries.xml" />
      <Folder Include="Assets/EikoYandex/Editor/Scripts" />
      <Folder Include="Assets/EikoYandex/Editor" />

+ 2 - 1
Assembly-CSharp.csproj

@@ -64,6 +64,7 @@
      <Compile Include="Assets/Epic Toon FX/Demo/Scripts/VFX Library/ParticleEffectsLibrary.cs" />
      <Compile Include="Assets/Epic Toon FX/Demo/Scripts/ETFXMouseOrbit.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetGameplay/Scripts/Character/JetCharacterDetection.cs" />
+     <Compile Include="Assets/PaperFold/Test/TestLevel.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetUI/Scripts/Shop/ShopManager.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetUI/LeanTween/Examples/Scripts/GeneralSimpleUI.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetUI/LeanTween/Examples/Scripts/PathSplineEndless.cs" />
@@ -170,7 +171,7 @@
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetUI/LeanTween/Examples/Scripts/GeneralBasic.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetUI/LeanTween/Examples/Archived/TestingRigidbodyCS.cs" />
      <Compile Include="Assets/_Packages/PaperFoldAsset/JetSystems/JetUI/LeanTween/Examples/Scripts/Following.cs" />
-     <Compile Include="Assets/PaperFold/Test/TestLevel.cs" />
+     <Compile Include="Assets/PaperFold/Scripts/FoldLinesGeneratorNew.cs" />
      <Folder Include="Assets" />
      <Folder Include="Assets/Epic Toon FX/Prefabs/Environment/Water/Other" />
      <Folder Include="Assets/_Packages/GUI Mobile Hyper-Casual/Sprites/Items PSD + PNG/Gun" />

+ 67 - 0
Assets/PaperFold/Scripts/FoldLinesGeneratorNew.cs

@@ -0,0 +1,67 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using JetSystems;
+
+public class FoldLinesGeneratorNew : MonoBehaviour
+{
+    [Header(" Components ")]
+    [SerializeField] private LineRenderer linePrefab;
+    private Paper currentPaper;
+    private void Awake()
+    {
+        // LevelManager.onPaperInstantiated += DrawFoldingLines;
+        // UIManager.onLevelCompleteSet += ClearPaperDelegates;
+    }
+
+   
+
+    private void OnDestroy()
+    {
+        
+    }
+
+    private void ClearPaperDelegates(int none)
+    {
+        currentPaper.onPaperStateChanged -= UpdateFoldingLines;
+        currentPaper = null;
+
+        UpdateFoldingLines();
+    }
+
+    public void DrawFoldingLines(Paper paper)
+    {
+        Debug.Log("DrawFoldingLines");
+        currentPaper = paper;
+        currentPaper.onPaperStateChanged += UpdateFoldingLines;
+
+        UpdateFoldingLines();
+    }
+
+    private void UpdateFoldingLines()
+    {
+        transform.Clear();
+
+        if (currentPaper == null) return;
+
+        Folding[] foldings = currentPaper.GetFoldings(false);
+
+        foreach (Folding folding in foldings)
+            if (!folding.IsFolded())
+                DrawFolding(folding);
+    }
+
+    private void DrawFolding(Folding folding)
+    {
+        LineRenderer line = Instantiate(linePrefab, transform);
+
+        Vector3[] foldingDirection = folding.GetRotationAxis().AsLine();
+
+        Vector3 p0 = foldingDirection[0].With(y: currentPaper.transform.position.y + -0.05f);
+        Vector3 p1 = foldingDirection[1].With(y: currentPaper.transform.position.y + -0.05f);
+
+        line.SetPosition(0, p0);
+        line.SetPosition(1, p1);
+    }
+}

+ 11 - 0
Assets/PaperFold/Scripts/FoldLinesGeneratorNew.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 937106cd17f78494fa8a84567a024430
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
Assets/PaperFold/Test/TestLevel.cs

@@ -9,7 +9,7 @@ using UnityEngine.ResourceManagement.AsyncOperations;
 public class TestLevel : MonoBehaviour
 {
     [SerializeField] private AssetReference papers;
-    [SerializeField] private FoldLinesGenerator foldLinesGenerator;
+    [SerializeField] private FoldLinesGeneratorNew foldLinesGenerator;
     private Paper currentPaper;
     public delegate void OnPaperInstantiated(Paper paper);
 

+ 7 - 10
Assets/_Packages/PaperFoldAsset/Paper Fold/Scripts/FoldLinesGenerator.cs

@@ -1,5 +1,4 @@
-using System;
-using System.Collections;
+using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using JetSystems;
@@ -9,17 +8,16 @@ public class FoldLinesGenerator : MonoBehaviour
     [Header(" Components ")]
     [SerializeField] private LineRenderer linePrefab;
     private Paper currentPaper;
+
     private void Awake()
     {
-        // LevelManager.onPaperInstantiated += DrawFoldingLines;
-        // UIManager.onLevelCompleteSet += ClearPaperDelegates;
+        LevelManager.onPaperInstantiated += DrawFoldingLines;
+        UIManager.onLevelCompleteSet += ClearPaperDelegates;
     }
 
-   
-
     private void OnDestroy()
     {
-        
+        LevelManager.onPaperInstantiated -= DrawFoldingLines;
     }
 
     private void ClearPaperDelegates(int none)
@@ -30,9 +28,8 @@ public class FoldLinesGenerator : MonoBehaviour
         UpdateFoldingLines();
     }
 
-    public void DrawFoldingLines(Paper paper)
+    private void DrawFoldingLines(Paper paper)
     {
-        Debug.Log("DrawFoldingLines");
         currentPaper = paper;
         currentPaper.onPaperStateChanged += UpdateFoldingLines;
 
@@ -64,4 +61,4 @@ public class FoldLinesGenerator : MonoBehaviour
         line.SetPosition(0, p0);
         line.SetPosition(1, p1);
     }
-}
+}