Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sdk-public
unity_sdk_demo
Commits
6df1b893
Commit
6df1b893
authored
Jan 19, 2026
by
gaorui
Browse files
Merge branch 'feat-dev-fixui' into 'feat-preserv'
feat(app): 修复动态 ui日志文字滚动问题,解决提示 purchasing 报错问题 See merge request
!21
parents
d95ddb07
8a58d58a
Changes
7
Show whitespace changes
Inline
Side-by-side
Assets/Scenes/SampleScene.unity
View file @
6df1b893
...
...
@@ -3989,7 +3989,7 @@ RectTransform:
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1562069058
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
5
0
}
m_LocalPosition
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_ConstrainProportionsScale
:
0
m_Children
:
[]
...
...
Assets/Scripts/demo/utils/LogViewer.cs
View file @
6df1b893
...
...
@@ -78,39 +78,56 @@ public class LogViewer : MonoBehaviour
logText
.
text
=
sb
.
ToString
();
// ✅ 动态计算 Text 实际高度
float
preferredHeight
=
CalculateTextHeight
(
logText
.
text
,
logText
);
RectTransform
contentRect
=
logText
.
GetComponent
<
RectTransform
>().
parent
as
RectTransform
;
if
(
contentRect
!=
null
)
// 动态设置尺寸
RectTransform
textRect
=
logText
.
GetComponent
<
RectTransform
>();
RectTransform
contentRect
=
scrollRect
.
content
;
RectTransform
viewportRect
=
scrollRect
.
viewport
;
if
(
textRect
!=
null
&&
contentRect
!=
null
&&
viewportRect
!=
null
)
{
contentRect
.
sizeDelta
=
new
Vector2
(
contentRect
.
sizeDelta
.
x
,
Mathf
.
Max
(
preferredHeight
,
500
));
// 设置 Text 和 Content 的宽度等于 Viewport 宽度
float
viewportWidth
=
viewportRect
.
rect
.
width
;
textRect
.
SetSizeWithCurrentAnchors
(
RectTransform
.
Axis
.
Horizontal
,
viewportWidth
);
contentRect
.
SetSizeWithCurrentAnchors
(
RectTransform
.
Axis
.
Horizontal
,
viewportWidth
);
// 计算文本内容的实际高度
float
textHeight
=
CalculateTextHeight
(
logText
.
text
,
logText
,
viewportWidth
);
// 设置 Content 的高度
contentRect
.
SetSizeWithCurrentAnchors
(
RectTransform
.
Axis
.
Vertical
,
textHeight
);
// 强制更新布局
LayoutRebuilder
.
ForceRebuildLayoutImmediate
(
contentRect
);
Canvas
.
ForceUpdateCanvases
();
}
// 自动滚动到底部
if
(
autoScroll
)
{
Canvas
.
ForceUpdateCanvases
();
StartCoroutine
(
ScrollToBottom
());
ScrollToBottomNow
();
}
}
//
✅ 计算 Text
实际高度
//
计算文本内容的
实际高度
[
Preserve
]
float
CalculateTextHeight
(
string
text
,
Text
textComponent
)
float
CalculateTextHeight
(
string
text
,
Text
textComponent
,
float
width
)
{
if
(
string
.
IsNullOrEmpty
(
text
))
return
0
;
return
100
;
// 创建生成设置
var
settings
=
textComponent
.
GetGenerationSettings
(
new
Vector2
(
width
,
0
));
// 获取文本的首选高度
float
height
=
textComponent
.
cachedTextGenerator
.
GetPreferredHeight
(
text
,
settings
);
var
style
=
textComponent
.
GetGenerationSettings
(
textComponent
.
rectTransform
.
rect
.
size
);
var
height
=
textComponent
.
cachedTextGenerator
.
GetPreferredHeight
(
text
,
style
);
return
height
/
textComponent
.
pixelsPerUnit
;
}
[
Preserve
]
IEnumerator
ScrollToBottom
()
void
ScrollToBottom
Now
()
{
yield
return
null
;
// 等待一帧
// 滚动到底部
scrollRect
.
verticalNormalizedPosition
=
0f
;
}
...
...
Packages/manifest.json
View file @
6df1b893
...
...
@@ -11,7 +11,6 @@
"com.unity.ide.visualstudio"
:
"2.0.22"
,
"com.unity.ide.vscode"
:
"1.2.5"
,
"com.unity.nuget.newtonsoft-json"
:
"3.2.1"
,
"com.unity.purchasing"
:
"4.11.0"
,
"com.unity.test-framework"
:
"1.1.33"
,
"com.unity.textmeshpro"
:
"3.0.7"
,
"com.unity.timeline"
:
"1.7.7"
,
...
...
Packages/packages-lock.json
View file @
6df1b893
...
...
@@ -22,7 +22,7 @@
"dependencies"
:
{
"com.unity.ugui"
:
"1.0.0"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.ai.navigation"
:
{
"version"
:
"1.1.6"
,
...
...
@@ -31,38 +31,38 @@
"dependencies"
:
{
"com.unity.modules.ai"
:
"1.0.0"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.analytics"
:
{
"version"
:
"3.8.1"
,
"depth"
:
0
,
"source"
:
"registry"
,
"dependencies"
:
{
"com.unity.
services.analytics
"
:
"1.0.
4
"
,
"com.unity.
ugui
"
:
"1.0.
0
"
"com.unity.
ugui
"
:
"1.0.
0
"
,
"com.unity.
services.analytics
"
:
"1.0.
4
"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.collab-proxy"
:
{
"version"
:
"2.10.0"
,
"depth"
:
0
,
"source"
:
"registry"
,
"dependencies"
:
{},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.editorcoroutines"
:
{
"version"
:
"1.0.0"
,
"depth"
:
1
,
"source"
:
"registry"
,
"dependencies"
:
{},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.ext.nunit"
:
{
"version"
:
"1.0.6"
,
"depth"
:
1
,
"source"
:
"registry"
,
"dependencies"
:
{},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.feature.development"
:
{
"version"
:
"1.0.1"
,
...
...
@@ -85,7 +85,7 @@
"dependencies"
:
{
"com.unity.ext.nunit"
:
"1.0.6"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.ide.visualstudio"
:
{
"version"
:
"2.0.22"
,
...
...
@@ -94,41 +94,28 @@
"dependencies"
:
{
"com.unity.test-framework"
:
"1.1.9"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.ide.vscode"
:
{
"version"
:
"1.2.5"
,
"depth"
:
0
,
"source"
:
"registry"
,
"dependencies"
:
{},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.nuget.newtonsoft-json"
:
{
"version"
:
"3.2.1"
,
"depth"
:
0
,
"source"
:
"registry"
,
"dependencies"
:
{},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.performance.profile-analyzer"
:
{
"version"
:
"1.2.3"
,
"depth"
:
1
,
"source"
:
"registry"
,
"dependencies"
:
{},
"url"
:
"https://packages.unity.cn"
},
"com.unity.purchasing"
:
{
"version"
:
"4.11.0"
,
"depth"
:
0
,
"source"
:
"registry"
,
"dependencies"
:
{
"com.unity.ugui"
:
"1.0.0"
,
"com.unity.modules.unitywebrequest"
:
"1.0.0"
,
"com.unity.modules.jsonserialize"
:
"1.0.0"
,
"com.unity.modules.androidjni"
:
"1.0.0"
,
"com.unity.services.core"
:
"1.8.2"
},
"url"
:
"https://packages.unity.cn"
"url"
:
"https://packages.unity.com"
},
"com.unity.services.analytics"
:
{
"version"
:
"6.0.3"
,
...
...
@@ -139,25 +126,25 @@
"com.unity.services.core"
:
"1.12.4"
,
"com.unity.modules.jsonserialize"
:
"1.0.0"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.services.core"
:
{
"version"
:
"1.14.0"
,
"depth"
:
1
,
"depth"
:
2
,
"source"
:
"registry"
,
"dependencies"
:
{
"com.unity.modules.androidjni"
:
"1.0.0"
,
"com.unity.nuget.newtonsoft-json"
:
"3.2.1"
,
"com.unity.modules.unitywebrequest"
:
"1.0.0"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.settings-manager"
:
{
"version"
:
"2.1.0"
,
"depth"
:
2
,
"source"
:
"registry"
,
"dependencies"
:
{},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.test-framework"
:
{
"version"
:
"1.1.33"
,
...
...
@@ -168,7 +155,7 @@
"com.unity.modules.imgui"
:
"1.0.0"
,
"com.unity.modules.jsonserialize"
:
"1.0.0"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.testtools.codecoverage"
:
{
"version"
:
"1.2.6"
,
...
...
@@ -178,7 +165,7 @@
"com.unity.test-framework"
:
"1.0.16"
,
"com.unity.settings-manager"
:
"1.0.1"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.textmeshpro"
:
{
"version"
:
"3.0.7"
,
...
...
@@ -187,7 +174,7 @@
"dependencies"
:
{
"com.unity.ugui"
:
"1.0.0"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.timeline"
:
{
"version"
:
"1.7.7"
,
...
...
@@ -199,7 +186,7 @@
"com.unity.modules.animation"
:
"1.0.0"
,
"com.unity.modules.particlesystem"
:
"1.0.0"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.ugui"
:
{
"version"
:
"1.0.0"
,
...
...
@@ -218,7 +205,7 @@
"com.unity.ugui"
:
"1.0.0"
,
"com.unity.modules.jsonserialize"
:
"1.0.0"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.xr.legacyinputhelpers"
:
{
"version"
:
"2.1.12"
,
...
...
@@ -228,7 +215,7 @@
"com.unity.modules.vr"
:
"1.0.0"
,
"com.unity.modules.xr"
:
"1.0.0"
},
"url"
:
"https://packages.unity.c
n
"
"url"
:
"https://packages.unity.c
om
"
},
"com.unity.modules.ai"
:
{
"version"
:
"1.0.0"
,
...
...
ProjectSettings/PackageManagerSettings.asset
View file @
6df1b893
...
...
@@ -21,7 +21,7 @@ MonoBehaviour:
m_Registries
:
-
m_Id
:
main
m_Name
:
m_Url
:
https://packages.unity.c
n
m_Url
:
https://packages.unity.c
om
m_Scopes
:
[]
m_IsDefault
:
1
m_Capabilities
:
7
...
...
@@ -31,6 +31,6 @@ MonoBehaviour:
m_RegistryInfoDraft
:
m_Modified
:
0
m_ErrorMessage
:
m_UserModificationsInstanceId
:
-83
6
m_OriginalInstanceId
:
-83
8
m_UserModificationsInstanceId
:
-83
4
m_OriginalInstanceId
:
-83
6
m_LoadAssets
:
0
ProjectSettings/ProjectSettings.asset
View file @
6df1b893
...
...
@@ -266,8 +266,8 @@ PlayerSettings:
useCustomProguardFile
:
1
AndroidTargetArchitectures
:
2
AndroidTargetDevices
:
0
AndroidSplashScreenScale
:
0
androidSplashScreen
:
{
fileID
:
0
}
AndroidSplashScreenScale
:
2
androidSplashScreen
:
{
fileID
:
2800000
,
guid
:
17c350171f7a3ca479f830547c66d187
,
type
:
3
}
AndroidKeystoreName
:
'
{dedicated}:
sds.keystore'
AndroidKeyaliasName
:
ft
AndroidEnableArmv9SecurityFeatures
:
0
...
...
ProjectSettings/UnityConnectSettings.asset
View file @
6df1b893
...
...
@@ -10,8 +10,6 @@ UnityConnectSettings:
m_EventUrl
:
https://cdp.cloud.unity3d.com/v1/events
m_ConfigUrl
:
https://config.uca.cloud.unity3d.com
m_DashboardUrl
:
https://dashboard.unity3d.com
m_CNEventUrl
:
https://cdp.cloud.unity.cn/v1/events
m_CNConfigUrl
:
https://cdp.cloud.unity.cn/config
m_TestInitMode
:
0
CrashReportingSettings
:
m_EventUrl
:
https://perf-events.cloud.unity.cn
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment