Quellcode durchsuchen

feat: 增加GUI界面

zhangwenjie vor 1 Jahr
Ursprung
Commit
189c85a79f

Datei-Diff unterdrückt, da er zu groß ist
+ 464 - 310
Assets/Resources/UI/MainWindow/MainWindow.prefab


+ 95 - 0
Assets/Scenes/MainScene.unity

@@ -232,6 +232,101 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 2
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &701804780
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 701804784}
+  - component: {fileID: 701804783}
+  - component: {fileID: 701804782}
+  - component: {fileID: 701804781}
+  m_Layer: 0
+  m_Name: Cube
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!65 &701804781
+BoxCollider:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 701804780}
+  m_Material: {fileID: 0}
+  m_IsTrigger: 0
+  m_Enabled: 1
+  serializedVersion: 2
+  m_Size: {x: 1, y: 1, z: 1}
+  m_Center: {x: 0, y: 0, z: 0}
+--- !u!23 &701804782
+MeshRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 701804780}
+  m_Enabled: 1
+  m_CastShadows: 1
+  m_ReceiveShadows: 1
+  m_DynamicOccludee: 1
+  m_MotionVectors: 1
+  m_LightProbeUsage: 1
+  m_ReflectionProbeUsage: 1
+  m_RayTracingMode: 2
+  m_RayTraceProcedural: 0
+  m_RenderingLayerMask: 1
+  m_RendererPriority: 0
+  m_Materials:
+  - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
+  m_StaticBatchInfo:
+    firstSubMesh: 0
+    subMeshCount: 0
+  m_StaticBatchRoot: {fileID: 0}
+  m_ProbeAnchor: {fileID: 0}
+  m_LightProbeVolumeOverride: {fileID: 0}
+  m_ScaleInLightmap: 1
+  m_ReceiveGI: 1
+  m_PreserveUVs: 0
+  m_IgnoreNormalsForChartDetection: 0
+  m_ImportantGI: 0
+  m_StitchLightmapSeams: 1
+  m_SelectedEditorRenderState: 3
+  m_MinimumChartSize: 4
+  m_AutoUVMaxDistance: 0.5
+  m_AutoUVMaxAngle: 89
+  m_LightmapParameters: {fileID: 0}
+  m_SortingLayerID: 0
+  m_SortingLayer: 0
+  m_SortingOrder: 0
+  m_AdditionalVertexStreams: {fileID: 0}
+--- !u!33 &701804783
+MeshFilter:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 701804780}
+  m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!4 &701804784
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 701804780}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 6.397044, y: -1.9895781, z: 5.971598}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_Children: []
+  m_Father: {fileID: 0}
+  m_RootOrder: 4
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
 --- !u!1 &1526898376
 GameObject:
   m_ObjectHideFlags: 0

+ 8 - 0
Assets/Scripts/Core/Animation.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 39a0940809835e44d848ab97322a7b11
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 71 - 0
Assets/Scripts/Core/Animation/AnimationManager.cs

@@ -0,0 +1,71 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class AnimationManager
+{
+    //帧动画变速
+   public void AnimationSpeed(int num,Animator animator)
+    {
+        try
+        {
+            animator.speed = 1 * num;
+        }
+        catch (System.Exception)
+        {
+
+            throw;
+        }
+        
+    }
+
+    public static void Animation(GameObject obj,Color[] colors,float frameRate)
+    {
+        AnimationClip clip = new AnimationClip();
+        clip.frameRate = frameRate;
+        clip.legacy = true;
+        Keyframe[][] keyframes = new Keyframe[4][];
+
+        for (int i = 0; i < 4; i++)
+        {
+            keyframes[i] = new Keyframe[colors.Length];
+        }
+
+        for (int i = 0; i < colors.Length; i++)
+        {
+            float time = i / frameRate;
+
+            keyframes[0][i] = new Keyframe(time, colors[i].r);
+            keyframes[1][i] = new Keyframe(time, colors[i].g);
+            keyframes[2][i] = new Keyframe(time, colors[i].b);
+            keyframes[3][i] = new Keyframe(time, colors[i].a);
+        }
+
+        //创建动画曲线,添加关键帧
+        AnimationCurve curveR = new AnimationCurve(keyframes[0]);
+        AnimationCurve curveG = new AnimationCurve(keyframes[1]);
+        AnimationCurve curveB = new AnimationCurve(keyframes[2]);
+        AnimationCurve curveA = new AnimationCurve(keyframes[3]);
+
+        //将动画曲线添加到剪辑中,一个动画通道对应一个颜色通道
+        clip.SetCurve("", typeof(Material), "_Color.r", curveR);
+        clip.SetCurve("", typeof(Material), "_Color.g", curveG);
+
+        clip.SetCurve("", typeof(Material), "_Color.b", curveB);
+        clip.SetCurve("", typeof(Material), "_Color.a", curveA);
+
+        if(obj.GetComponent<Animation>() == null)
+        {
+            obj.AddComponent<Animation>();
+        }
+
+        obj.GetComponent<Animation>().AddClip(clip, "anicol");
+
+        
+        Animation ani = obj.GetComponent<Animation>();
+        ani.AddClip(clip, "anicol");
+        ani.clip = clip;
+        //播放动画
+        ani.Play("anicol");
+    }
+}

+ 11 - 0
Assets/Scripts/Core/Animation/AnimationManager.cs.meta

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

+ 19 - 0
Assets/Scripts/UI/MainWindow/MainGUI.cs

@@ -0,0 +1,19 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class MainGUI : MonoBehaviour
+{
+    // Start is called before the first frame update
+    void Start()
+    {
+        
+    }
+
+    // Update is called once per frame
+    void Update()
+    {
+        
+    }
+  
+}

+ 11 - 0
Assets/Scripts/UI/MainWindow/MainGUI.cs.meta

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

+ 7 - 0
Assets/Scripts/UI/MainWindow/MainWindow.cs

@@ -11,6 +11,7 @@ namespace XiZiZhiShu
 
         public ExpandableView ExpandScroll;
         public Slider vidor;
+        public GameObject testObj;
         //UI的初始化请放在这里
         public override void OnOpen()
         {
@@ -33,6 +34,12 @@ namespace XiZiZhiShu
         private void OnClickVidiocontrol(InputUIOnClickEvent inputEvent)
         {
              Debug.Log("播放或者暂停");
+            Color[] colors = new Color[1];
+            Color color = new Color();
+            color = Color.red;
+            colors[0] = color;
+            testObj = GameObject.Find("Cube");
+            AnimationManager.Animation(testObj,colors, 60);
         }
 
         //打开文件按钮事件回调

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.