From 197897a32384ad2915408121a1c79a50b244b592 Mon Sep 17 00:00:00 2001 From: bob <605277374@qq.com> Date: Mon, 23 Jun 2025 18:08:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=BE=E7=A4=BA3d=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Examples/RenderTexture/RenderImage.cs | 5 +- .../Resources/Role/Materials/U1NPC0040.mat | 4 +- Assets/Resources/Fgui/Common/Common_fui.bytes | Bin 33286 -> 33638 bytes Assets/Resources/Fgui/Main/Main_fui.bytes | Bin 12037 -> 12145 bytes Assets/Scripts/UI/Binders/CommonBinder.cs | 1 + Assets/Scripts/UI/Common/ModelRenderImage.cs | 297 ++++++++++++++++++ .../UI/Common/ModelRenderImage.cs.meta | 3 + .../UI/Common/ModelTexture.Designer.cs | 27 ++ .../UI/Common/ModelTexture.Designer.cs.meta | 2 + Assets/Scripts/UI/Common/ModelTexture.cs | 38 +++ Assets/Scripts/UI/Common/ModelTexture.cs.meta | 2 + Assets/Scripts/UI/Home/HomePanel.Designer.cs | 2 + .../UI/Home/Pages/HomeMainPage.Designer.cs | 2 + Assets/Scripts/UI/Home/Pages/HomeMainPage.cs | 6 +- Assets/Scripts/UI/Settings/SettingPanel.cs | 2 + .../Roboto-Bold SDF - HDRP Unlit.mat | 31 +- .../assets/Common/Com/ModelTexture.xml | 11 + FGUIProject/assets/Common/package.xml | 5 +- .../Main/Com/Home/Pages/HomeMainPage.xml | 5 +- FGUIProject/assets/Main/HomePanel.xml | 2 +- .../settings/whoot/6hgkvlau5dtxm9.json | 1 + 21 files changed, 427 insertions(+), 19 deletions(-) create mode 100644 Assets/Scripts/UI/Common/ModelRenderImage.cs create mode 100644 Assets/Scripts/UI/Common/ModelRenderImage.cs.meta create mode 100644 Assets/Scripts/UI/Common/ModelTexture.Designer.cs create mode 100644 Assets/Scripts/UI/Common/ModelTexture.Designer.cs.meta create mode 100644 Assets/Scripts/UI/Common/ModelTexture.cs create mode 100644 Assets/Scripts/UI/Common/ModelTexture.cs.meta create mode 100644 FGUIProject/assets/Common/Com/ModelTexture.xml create mode 100644 FGUIProject/settings/whoot/6hgkvlau5dtxm9.json diff --git a/Assets/Plugins/FairyGUI/Examples/RenderTexture/RenderImage.cs b/Assets/Plugins/FairyGUI/Examples/RenderTexture/RenderImage.cs index 5b8f035b2..a4230ec2a 100644 --- a/Assets/Plugins/FairyGUI/Examples/RenderTexture/RenderImage.cs +++ b/Assets/Plugins/FairyGUI/Examples/RenderTexture/RenderImage.cs @@ -162,8 +162,8 @@ public class RenderImage float vh = imageRect.height - (sourceH - gridRect.height); uvRect = Rect.MinMaxRect(Mathf.Lerp(uvRect.xMin, uvRect.xMax, (bound.x - gridRect.x) / vw), Mathf.Lerp(uvRect.yMin, uvRect.yMax, (imageRect.height - bound.yMax - (sourceH - gridRect.yMax)) / vh), - Mathf.Lerp(uvRect.xMin, uvRect.xMax, (bound.xMax - gridRect.x) / vw), - Mathf.Lerp(uvRect.yMin, uvRect.yMax, (imageRect.height - bound.yMin - gridRect.y) / vh)); + Mathf.Lerp(uvRect.xMin, uvRect.xMax, (bound.xMax - gridRect.x) / vw), + Mathf.Lerp(uvRect.yMin, uvRect.yMax, (imageRect.height - bound.yMin - gridRect.y) / vh)); } else { @@ -201,6 +201,7 @@ public class RenderImage Object.Destroy(_model.gameObject); _model = null; } + _rotating = 0; } diff --git a/Assets/Plugins/FairyGUI/Examples/Resources/Role/Materials/U1NPC0040.mat b/Assets/Plugins/FairyGUI/Examples/Resources/Role/Materials/U1NPC0040.mat index 95e124d9d..683addd3c 100644 --- a/Assets/Plugins/FairyGUI/Examples/Resources/Role/Materials/U1NPC0040.mat +++ b/Assets/Plugins/FairyGUI/Examples/Resources/Role/Materials/U1NPC0040.mat @@ -13,8 +13,6 @@ Material: m_ModifiedSerializedProperties: 0 m_ValidKeywords: - _EMISSION - - _GLOSSINESS_FROM_BASE_ALPHA - - _SPECULAR_COLOR m_InvalidKeywords: [] m_LightmapFlags: 1 m_EnableInstancingVariants: 0 @@ -53,7 +51,7 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MainTex: - m_Texture: {fileID: 0} + m_Texture: {fileID: 2800000, guid: 3c3eb5b459fd6d241afe2698a33268d9, type: 3} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MetallicGlossMap: diff --git a/Assets/Resources/Fgui/Common/Common_fui.bytes b/Assets/Resources/Fgui/Common/Common_fui.bytes index 4d453ce38d245d8d6f7b627086e719a891eb15a0..91624d2e94a6968b9548d71ca60238f8fb7d9ce7 100644 GIT binary patch delta 4997 zcmaKv3tUxI_Q&_yo5KYz0?Om^y1)evA{TiJ%3H+;i1Jbq5D@{*SE%V^Hm2F6g{8*o zHO%}SwK8)uUo|!Mu^~+_i7BE=$o?xNgq-1dgy{D%;^Oh7FY$zS<9y`4&|7B_KdNV8faLiuD!7C#)4 zq}F0?CquI7X7&nASL?(roEzF;Ta6+83Z8pI%hj!7J)aFtr41YymalFTw{vCKTzi+m z!g)TN9^qCSG5h9-VceDJ@7=4!9pX+-a?Di-wJjn@+{KH- zV^z0c-W;AqTlh$LGQQ7+k5YG|&CrN!x`&%0^0j-#eW+efM3cH-{F*OCOr#zj9XZ~% z2}A4_zu`@hxrlr@GF|(v_&+Sjw~>|pTd}7^K>rUSQ2dT-q9SbD5WF4DmqyjlT7EIA zHf9IL-ee;Tq)3bwld;xKqRCgRL*N7ALC%hzZhHuNr+ApRM34@s6}qYyvxM+L!o6Z2b4(8H=htFJ zYX`(Z@i+&>Rt|o`9J2TWhWw;aRvX_OAFiIlURxhqqy8ukac}Ho+tbMKjChvQ;%d}$ z;xMm^E2KSqI4&Xjd9ie$!-3hnV9wwOUx_QzUW9&$C%6)9hV^Cf3NLl#)2sZb%dK7$ zuXC@fMLQ~vi9d01d=vedd*bWVaqP4&<0sPzE>2iLCwZxK@bd|F^@ezpk0&%~e?j^7 zb6R4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Ar_rTjGeS8$00S6Q!!K}2)BcQ=y6kxzaa{cyUnB8v+|7~14YjGg{1$fGk?Sq1yrve#S+p+#>n7FG_nK?A^>*im_(ZPwKA5bcT4ki x)7M)XwscO{*z?A!9(1_s1}CN>jc|(); + _camera.transform.position = new Vector3(0, 1000, 0); + _camera.cullingMask = 1 << RENDER_LAYER; + _camera.enabled = false; + Object.DontDestroyOnLoad(_camera.gameObject); + + this._root = new GameObject("RenderImage").transform; + this._root.SetParent(_camera.transform, false); + SetLayer(this._root.gameObject, HIDDEN_LAYER); + + this.modelRoot = new GameObject("model_root").transform; + this.modelRoot.SetParent(this._root, false); + + this._background = new GameObject("background").transform; + this._background.SetParent(this._root, false); + + this._image.onAddedToStage.Add(OnAddedToStage); + this._image.onRemovedFromStage.Add(OnRemoveFromStage); + + if (this._image.stage != null) + OnAddedToStage(); + else + _camera.gameObject.SetActive(false); + } + + public void Dispose() + { + Object.Destroy(_camera.gameObject); + DestroyTexture(); + + this._image.Dispose(); + this._image = null; + } + + /// + /// The rendertexture is not transparent. So if you want to the UI elements can be seen in the back of the models/particles in rendertexture, + /// you can set a maximunm two images for background. + /// Be careful if your image is 9 grid scaling, you must make sure the place holder is inside the middle box(dont cover from border to middle). + /// + /// + public void SetBackground(GObject image) + { + SetBackground(image, null); + } + + /// + /// The rendertexture is not transparent. So if you want to the UI elements can be seen in the back of the models/particles in rendertexture, + /// you can set a maximunm two images for background. + /// + /// + /// + public void SetBackground(GObject image1, GObject image2) + { + Image source1 = (Image)image1.displayObject; + Image source2 = image2 != null ? (Image)image2.displayObject : null; + + Vector3 pos = _background.position; + pos.z = _camera.farClipPlane; + _background.position = pos; + + Vector2[] uv = new Vector2[4]; + Vector2[] uv2 = null; + + Rect rect = _image.TransformRect(new Rect(0, 0, this._width, this._height), source1); + Rect uvRect = GetImageUVRect(source1, rect, uv); + + if (source2 != null) + { + rect = _image.TransformRect(new Rect(0, 0, this._width, this._height), source2); + uv2 = new Vector2[4]; + GetImageUVRect(source2, rect, uv2); + } + + Vector3[] vertices = new Vector3[4]; + for (int i = 0; i < 4; i++) + { + Vector2 v = uv[i]; + vertices[i] = new Vector3((v.x - uvRect.x) / uvRect.width * 2 - 1, + (v.y - uvRect.y) / uvRect.height * 2 - 1, 0); + } + + Mesh mesh = new Mesh(); + mesh.vertices = vertices; + mesh.uv = uv; + if (uv2 != null) + mesh.uv2 = uv2; + mesh.colors32 = new Color32[] { Color.white, Color.white, Color.white, Color.white }; + mesh.triangles = new int[] { 0, 1, 2, 2, 3, 0 }; + + MeshFilter meshFilter = this._background.gameObject.GetComponent(); + if (meshFilter == null) + meshFilter = this._background.gameObject.AddComponent(); + meshFilter.mesh = mesh; + MeshRenderer meshRenderer = this._background.gameObject.GetComponent(); + if (meshRenderer == null) + meshRenderer = this._background.gameObject.AddComponent(); +#if (UNITY_5 || UNITY_5_3_OR_NEWER) + meshRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; +#else + meshRenderer.castShadows = false; +#endif + meshRenderer.receiveShadows = false; + Shader shader = Shader.Find("Game/FullScreen"); + Material mat = new Material(shader); + mat.mainTexture = source1.texture.nativeTexture; + if (source2 != null) + mat.SetTexture("_Tex2", source2.texture.nativeTexture); + meshRenderer.material = mat; + } + + Rect GetImageUVRect(Image image, Rect localRect, Vector2[] uv) + { + Rect imageRect = new Rect(0, 0, image.size.x, image.size.y); + Rect bound = ToolSet.Intersection(ref imageRect, ref localRect); + Rect uvRect = image.texture.uvRect; + + if (image.scale9Grid != null) + { + Rect gridRect = (Rect)image.scale9Grid; + float sourceW = image.texture.width; + float sourceH = image.texture.height; + uvRect = Rect.MinMaxRect(Mathf.Lerp(uvRect.xMin, uvRect.xMax, gridRect.xMin / sourceW), + Mathf.Lerp(uvRect.yMin, uvRect.yMax, (sourceH - gridRect.yMax) / sourceH), + Mathf.Lerp(uvRect.xMin, uvRect.xMax, gridRect.xMax / sourceW), + Mathf.Lerp(uvRect.yMin, uvRect.yMax, (sourceH - gridRect.yMin) / sourceH)); + + float vw = imageRect.width - (sourceW - gridRect.width); + float vh = imageRect.height - (sourceH - gridRect.height); + uvRect = Rect.MinMaxRect(Mathf.Lerp(uvRect.xMin, uvRect.xMax, (bound.x - gridRect.x) / vw), + Mathf.Lerp(uvRect.yMin, uvRect.yMax, + (imageRect.height - bound.yMax - (sourceH - gridRect.yMax)) / vh), + Mathf.Lerp(uvRect.xMin, uvRect.xMax, (bound.xMax - gridRect.x) / vw), + Mathf.Lerp(uvRect.yMin, uvRect.yMax, (imageRect.height - bound.yMin - gridRect.y) / vh)); + } + else + { + uvRect = Rect.MinMaxRect(Mathf.Lerp(uvRect.xMin, uvRect.xMax, bound.xMin / imageRect.width), + Mathf.Lerp(uvRect.yMin, uvRect.yMax, (imageRect.height - bound.yMax) / imageRect.height), + Mathf.Lerp(uvRect.xMin, uvRect.xMax, bound.xMax / imageRect.width), + Mathf.Lerp(uvRect.yMin, uvRect.yMax, (imageRect.height - bound.yMin) / imageRect.height)); + } + + uv[0] = uvRect.position; + uv[1] = new Vector2(uvRect.xMin, uvRect.yMax); + uv[2] = new Vector2(uvRect.xMax, uvRect.yMax); + uv[3] = new Vector2(uvRect.xMax, uvRect.yMin); + + if (image.texture.rotated) + ToolSet.RotateUV(uv, ref image.texture.uvRect); + + return uvRect; + } + + public void LoadModel(string model) + { + this.UnloadModel(); + + Object prefab = Resources.Load(model); + GameObject go = ((GameObject)Object.Instantiate(prefab)); + _model = go.transform; + _model.SetParent(this.modelRoot, false); + } + + public void UnloadModel() + { + if (_model != null) + { + Object.Destroy(_model.gameObject); + _model = null; + } + + _rotating = 0; + } + + public void StartRotate(float delta) + { + _rotating = delta; + } + + public void StopRotate() + { + _rotating = 0; + } + + void CreateTexture() + { + if (_renderTexture != null) + return; + + _renderTexture = new RenderTexture(_width, _height, 24, RenderTextureFormat.ARGB32) + { + antiAliasing = 1, + filterMode = FilterMode.Bilinear, + anisoLevel = 0, + useMipMap = false + }; + this._image.texture = new NTexture(_renderTexture); + // this._image.blendMode = BlendMode.Off; + } + + void DestroyTexture() + { + if (_renderTexture != null) + { + Object.Destroy(_renderTexture); + _renderTexture = null; + this._image.texture = null; + } + } + + void OnAddedToStage() + { + if (_renderTexture == null) + CreateTexture(); + + Timers.inst.AddUpdate(this.Render); + _camera.gameObject.SetActive(true); + + Render(); + } + + void OnRemoveFromStage() + { + if (!_cacheTexture) + DestroyTexture(); + + Timers.inst.Remove(this.Render); + _camera.gameObject.SetActive(false); + } + + void Render(object param = null) + { + if (_rotating != 0 && this.modelRoot != null) + { + Vector3 localRotation = this.modelRoot.localRotation.eulerAngles; + localRotation.y += _rotating; + this.modelRoot.localRotation = Quaternion.Euler(localRotation); + } + + SetLayer(this._root.gameObject, RENDER_LAYER); + + _camera.targetTexture = this._renderTexture; + RenderTexture old = RenderTexture.active; + RenderTexture.active = this._renderTexture; + GL.Clear(true, true, Color.clear); + _camera.Render(); + RenderTexture.active = old; + + SetLayer(this._root.gameObject, HIDDEN_LAYER); + } + + void SetLayer(GameObject go, int layer) + { + Transform[] transforms = go.GetComponentsInChildren(true); + foreach (Transform t in transforms) + { + t.gameObject.layer = layer; + } + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Common/ModelRenderImage.cs.meta b/Assets/Scripts/UI/Common/ModelRenderImage.cs.meta new file mode 100644 index 000000000..1fea50440 --- /dev/null +++ b/Assets/Scripts/UI/Common/ModelRenderImage.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 82ec71c75abc4b739fb8e75078dd718b +timeCreated: 1750673117 \ No newline at end of file diff --git a/Assets/Scripts/UI/Common/ModelTexture.Designer.cs b/Assets/Scripts/UI/Common/ModelTexture.Designer.cs new file mode 100644 index 000000000..be03fcc3a --- /dev/null +++ b/Assets/Scripts/UI/Common/ModelTexture.Designer.cs @@ -0,0 +1,27 @@ +/**本脚本为自动生成,每次生成会覆盖!请勿手动修改,生成插件文档及项目地址:https://git.whoot.com/whoot-games/whoot.fguieditorplugin**/ + + +using FairyGUI; +using FairyGUI.Utils; +using NBC; + +namespace NBF +{ + public partial class ModelTexture + { + public const string URL = "ui://6hgkvlau5dtxm9"; + + public GGraph ModelHolder; + public GGraph TouchHolder; + + public override void ConstructFromXML(XML xml) + { + base.ConstructFromXML(xml); + + ModelHolder = (GGraph)GetChild("ModelHolder"); + TouchHolder = (GGraph)GetChild("TouchHolder"); + OnInited(); + UILanguage.TrySetComponentLanguage(this); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Common/ModelTexture.Designer.cs.meta b/Assets/Scripts/UI/Common/ModelTexture.Designer.cs.meta new file mode 100644 index 000000000..840c0e4a8 --- /dev/null +++ b/Assets/Scripts/UI/Common/ModelTexture.Designer.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: db45948262d06f64299721282226d4f2 \ No newline at end of file diff --git a/Assets/Scripts/UI/Common/ModelTexture.cs b/Assets/Scripts/UI/Common/ModelTexture.cs new file mode 100644 index 000000000..bc98aaf53 --- /dev/null +++ b/Assets/Scripts/UI/Common/ModelTexture.cs @@ -0,0 +1,38 @@ +// 本脚本只在不存在时会生成一次。组件逻辑写在当前脚本内。已存在不会再次生成覆盖 + +using UnityEngine; +using FairyGUI; +using NBC; + +namespace NBF +{ + public partial class ModelTexture : GComponent + { + ModelRenderImage _renderImage; + + private void OnInited() + { + _renderImage = new ModelRenderImage(ModelHolder.asGraph); + //RenderImage是不透明的,可以设置最多两张图片作为背景图 + // _renderImage.SetBackground(contentPane.GetChild("frame").asCom.GetChild("n0"), contentPane.GetChild("n20")); + } + + public void LoadModel(string model) + { + _renderImage.LoadModel("Role/npc"); + _renderImage.modelRoot.localPosition = new Vector3(0, -1.0f, 5f); + _renderImage.modelRoot.localScale = new Vector3(1, 1, 1); + _renderImage.modelRoot.localRotation = Quaternion.Euler(0, 120, 0); + } + + public void SetBackground(GObject image1) + { + _renderImage.SetBackground(image1); + } + + public void SetBackground(GObject image1, GObject image2) + { + _renderImage.SetBackground(image1, image2); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/UI/Common/ModelTexture.cs.meta b/Assets/Scripts/UI/Common/ModelTexture.cs.meta new file mode 100644 index 000000000..49c0d7cb2 --- /dev/null +++ b/Assets/Scripts/UI/Common/ModelTexture.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6b09786333c422145abf84aaa2750425 \ No newline at end of file diff --git a/Assets/Scripts/UI/Home/HomePanel.Designer.cs b/Assets/Scripts/UI/Home/HomePanel.Designer.cs index dd68e4a2c..4b99e54cb 100644 --- a/Assets/Scripts/UI/Home/HomePanel.Designer.cs +++ b/Assets/Scripts/UI/Home/HomePanel.Designer.cs @@ -11,6 +11,8 @@ namespace NBF public partial class HomePanel { public GObject this[string aKey] => ContentPane.GetChild(aKey); + [AutoFind(Name = "Back")] + public GLabel Back; [AutoFind(Name = "Pages")] public GComponent Pages; [AutoFind(Name = "Menu")] diff --git a/Assets/Scripts/UI/Home/Pages/HomeMainPage.Designer.cs b/Assets/Scripts/UI/Home/Pages/HomeMainPage.Designer.cs index c7706415c..9cc16d0ed 100644 --- a/Assets/Scripts/UI/Home/Pages/HomeMainPage.Designer.cs +++ b/Assets/Scripts/UI/Home/Pages/HomeMainPage.Designer.cs @@ -13,6 +13,7 @@ namespace NBF public HomeButtonGroups OpGroup; public BottomMenu BottomMenu; + public ModelTexture Model; public override void ConstructFromXML(XML xml) { @@ -20,6 +21,7 @@ namespace NBF OpGroup = (HomeButtonGroups)GetChild("OpGroup"); BottomMenu = (BottomMenu)GetChild("BottomMenu"); + Model = (ModelTexture)GetChild("Model"); OnInited(); UILanguage.TrySetComponentLanguage(this); } diff --git a/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs b/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs index 9369dc5d0..46f57f307 100644 --- a/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs +++ b/Assets/Scripts/UI/Home/Pages/HomeMainPage.cs @@ -31,6 +31,10 @@ namespace NBF { InputManager.OnUICanceled += OnUICanceled; UseBottomMenu(); + + + Model.LoadModel(string.Empty); + // Model.SetBackground(Panel.Back.GetChild("back"));//, Panel.Back.GetChild("icon") } @@ -73,7 +77,7 @@ namespace NBF private void UseBottomMenu() { BottomMenu.Use(Panel); - + BottomMenu.AddRightButton(InputDef.UI.Enter); BottomMenu.AddRightButton(InputDef.UI.Back); } diff --git a/Assets/Scripts/UI/Settings/SettingPanel.cs b/Assets/Scripts/UI/Settings/SettingPanel.cs index 4aea1d956..a94529ead 100644 --- a/Assets/Scripts/UI/Settings/SettingPanel.cs +++ b/Assets/Scripts/UI/Settings/SettingPanel.cs @@ -144,6 +144,8 @@ namespace NBF } ResetSettingList(); + + Notices.Success("TEXT_OP_SUCCESS"); } private void OnUICanceled(string action) diff --git a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF - HDRP Unlit.mat b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF - HDRP Unlit.mat index 27a2fd06f..c4cc4b41f 100644 --- a/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF - HDRP Unlit.mat +++ b/Assets/TextMesh Pro/Examples & Extras/Resources/Fonts & Materials/Roboto-Bold SDF - HDRP Unlit.mat @@ -2,14 +2,20 @@ %TAG !u! tag:unity3d.com,2011: --- !u!21 &2100000 Material: - serializedVersion: 6 + serializedVersion: 8 m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: Roboto-Bold SDF - HDRP Unlit m_Shader: {fileID: -6465566751694194690, guid: f63d574838ccfb44f84acc05fed0af48, type: 3} - m_ShaderKeywords: _ALPHATEST_ON _ENABLE_FOG_ON_TRANSPARENT _SURFACE_TYPE_TRANSPARENT + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: + - _ALPHATEST_ON + - _ENABLE_FOG_ON_TRANSPARENT + - _SURFACE_TYPE_TRANSPARENT + m_InvalidKeywords: [] m_LightmapFlags: 1 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 @@ -22,6 +28,7 @@ Material: - TransparentDepthPostpass - TransparentBackface - MOTIONVECTORS + m_LockedProperties: m_SavedProperties: serializedVersion: 3 m_TexEnvs: @@ -57,6 +64,7 @@ Material: m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} + m_Ints: [] m_Floats: - _AddPrecomputedVelocity: 0 - _AlphaCutoffEnable: 1 @@ -76,15 +84,19 @@ Material: - _BumpFace: 0 - _BumpOutline: 0 - _ColorMask: 15 + - _ConservativeDepthOffsetEnable: 0 - _CullMode: 2 - _CullModeForward: 2 - _DepthOffsetEnable: 0 - _Diffuse: 0.5 - _DoubleSidedEnable: 0 + - _DoubleSidedGIMode: 0 - _DoubleSidedNormalMode: 2 - _DstBlend: 10 + - _DstBlend2: 10 - _EnableBlendModePreserveSpecularLighting: 0 - _EnableFogOnTransparent: 1 + - _ExcludeFromTUAndAA: 0 - _FaceDilate: 0 - _FaceUVSpeedX: 0 - _FaceUVSpeedY: 0 @@ -102,6 +114,7 @@ Material: - _OutlineUVSpeedX: 0 - _OutlineUVSpeedY: 0 - _OutlineWidth: 0 + - _PerPixelSorting: 0 - _PerspectiveFilter: 0.875 - _Reflectivity: 10 - _RenderQueueType: 3 @@ -119,15 +132,15 @@ Material: - _StencilOp: 0 - _StencilReadMask: 255 - _StencilRef: 0 - - _StencilRefDepth: 0 + - _StencilRefDepth: 1 - _StencilRefDistortionVec: 4 - _StencilRefGBuffer: 2 - - _StencilRefMV: 32 + - _StencilRefMV: 33 - _StencilWriteMask: 6 - - _StencilWriteMaskDepth: 8 + - _StencilWriteMaskDepth: 9 - _StencilWriteMaskDistortionVec: 4 - _StencilWriteMaskGBuffer: 14 - - _StencilWriteMaskMV: 40 + - _StencilWriteMaskMV: 43 - _SurfaceType: 1 - _TextureHeight: 1024 - _TextureWidth: 1024 @@ -176,6 +189,7 @@ Material: - _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5} - _UnderlayOffset: {r: 0, g: 0, b: 0, a: 0} m_BuildTextureStacks: [] + m_AllowLocking: 1 --- !u!114 &8695414737614723888 MonoBehaviour: m_ObjectHideFlags: 11 @@ -188,4 +202,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} m_Name: m_EditorClassIdentifier: - version: 11 + version: 13 + hdPluginSubTargetMaterialVersions: + m_Keys: [] + m_Values: diff --git a/FGUIProject/assets/Common/Com/ModelTexture.xml b/FGUIProject/assets/Common/Com/ModelTexture.xml new file mode 100644 index 000000000..baa442d51 --- /dev/null +++ b/FGUIProject/assets/Common/Com/ModelTexture.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/FGUIProject/assets/Common/package.xml b/FGUIProject/assets/Common/package.xml index 747fa9107..751459ee0 100644 --- a/FGUIProject/assets/Common/package.xml +++ b/FGUIProject/assets/Common/package.xml @@ -220,10 +220,7 @@ - - - - + \ No newline at end of file diff --git a/FGUIProject/assets/Main/Com/Home/Pages/HomeMainPage.xml b/FGUIProject/assets/Main/Com/Home/Pages/HomeMainPage.xml index c43c2a576..1b26c2bb2 100644 --- a/FGUIProject/assets/Main/Com/Home/Pages/HomeMainPage.xml +++ b/FGUIProject/assets/Main/Com/Home/Pages/HomeMainPage.xml @@ -2,10 +2,13 @@ - + + + + \ No newline at end of file diff --git a/FGUIProject/assets/Main/HomePanel.xml b/FGUIProject/assets/Main/HomePanel.xml index 0aac27122..a0497b683 100644 --- a/FGUIProject/assets/Main/HomePanel.xml +++ b/FGUIProject/assets/Main/HomePanel.xml @@ -1,7 +1,7 @@ - + diff --git a/FGUIProject/settings/whoot/6hgkvlau5dtxm9.json b/FGUIProject/settings/whoot/6hgkvlau5dtxm9.json new file mode 100644 index 000000000..eaf9875c7 --- /dev/null +++ b/FGUIProject/settings/whoot/6hgkvlau5dtxm9.json @@ -0,0 +1 @@ +{"url":"ui://6hgkvlau5dtxm9","name":"ModelTexture","scriptType":"component","isCustomName":false,"customName":"","annotation":"","member":{}} \ No newline at end of file