比较提交

...

2 次代码提交

作者 SHA1 备注 提交日期
Xingwei Zhu 6090fab0 stash changes 3 年前
xingweizhu 58677882 stash changes 3 年前
共有 17 个文件被更改,包括 1234 次插入10 次删除
  1. 40
      com.unity.uiwidgets/Runtime/rendering/texture.cs
  2. 19
      com.unity.uiwidgets/Runtime/widgets/texture.cs
  3. 1
      engine/Build.bee.cs
  4. 13
      engine/src/shell/platform/unity/android/uiwidgets_panel.cc
  5. 634
      Samples/UIWidgetsSamples_2019_4/Assets/Scene/3DTest1.unity
  6. 7
      Samples/UIWidgetsSamples_2019_4/Assets/Scene/3DTest1.unity.meta
  7. 8
      Samples/UIWidgetsSamples_2019_4/Assets/Resources.meta
  8. 3
      Samples/UIWidgetsSamples_2019_4/Assets/Script/ModelViewHelper.cs.meta
  9. 3
      Samples/UIWidgetsSamples_2019_4/Assets/Script/Scene3DTest1.cs.meta
  10. 102
      Samples/UIWidgetsSamples_2019_4/Assets/Script/ModelViewHelper.cs
  11. 92
      Samples/UIWidgetsSamples_2019_4/Assets/Script/Scene3DTest1.cs
  12. 72
      engine/src/shell/platform/unity/android/unity_external_texture_gl.cc
  13. 40
      engine/src/shell/platform/unity/android/unity_external_texture_gl.h
  14. 7
      Samples/UIWidgetsSamples_2019_4/Assets/Resources/CubPrefab.prefab.meta
  15. 203
      Samples/UIWidgetsSamples_2019_4/Assets/Resources/CubPrefab.prefab

40
com.unity.uiwidgets/Runtime/rendering/texture.cs


using System;
using Unity.UIWidgets.async;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;

public TextureBox(int textureId) {
public TextureBox(int? textureId, Texture texture) {
_texture = texture;
Texture _texture;
public int? textureId {
get { return _textureId; }

}
int? _textureId;
Timer _timer;
bool _frameCallbackScheduled;
protected override bool sizedByParent {
get { return true; }

return true;
}
void _scheduleAppFrame() {
if (_frameCallbackScheduled || textureId == null) {
return;
}
_frameCallbackScheduled = true;
SchedulerBinding.instance.scheduleFrameCallback(_handleAppFrame);
}
void _handleAppFrame(TimeSpan timestamp) {
_frameCallbackScheduled = false;
if (textureId == null) {
return;
}
TimeSpan delay = TimeSpan.Zero;
delay = new TimeSpan((long) (delay.Ticks * scheduler_.timeDilation));
_timer = Timer.create(delay, () => _scheduleAppFrame());
}
if (_texture != null) {
markNeedsLayout();
SchedulerBinding.instance.scheduleFrameCallback(_handleAppFrame);
if (_texture.GetNativeTexturePtr() != IntPtr.Zero) {
_textureId = UIWidgetsPanelWrapper.current.registerTexture(_texture);
}
}
_scheduleAppFrame();
context.addLayer(new TextureLayer(
rect: Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height),
textureId: _textureId.Value

19
com.unity.uiwidgets/Runtime/widgets/texture.cs


using System;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;

public Texture(
Key key = null,
UnityEngine.Texture texture = null,
D.assert(textureId != null);
this.textureId = textureId.Value;
this.textureId = textureId;
this.texture = texture;
if (texture != null && texture.GetNativeTexturePtr() != IntPtr.Zero) {
this.textureId = UIWidgetsPanelWrapper.current.registerTexture(texture);
}
public readonly int textureId;
public readonly int? textureId;
public readonly UnityEngine.Texture texture;
return new TextureBox(textureId: textureId);
return new TextureBox(textureId: textureId, texture: texture);
}
public override bool Equals(object obj) {
return false;
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {

1
engine/Build.bee.cs


"src/shell/platform/unity/android/uiwidgets_system.cc",
"src/shell/platform/unity/android/android_task_runner.cc",
"src/shell/platform/unity/android/uiwidgets_panel.cc",
"src/shell/platform/unity/android/unity_external_texture_gl.cc"
};
var iosSources = new NPath[] {

13
engine/src/shell/platform/unity/android/uiwidgets_panel.cc


#include "shell/common/switches.h"
#include "shell/platform/embedder/embedder_engine.h"
#include "uiwidgets_system.h"
#include "unity_external_texture_gl.h"
#include "third_party/Unity/IUnityGraphics.h"
namespace uiwidgets

int UIWidgetsPanel::RegisterTexture(void *native_texture_ptr)
{
std::cerr << "registering external texture is not implemented for android" << std::endl;
int texture_identifier = 0;
//int texture_identifier = 0;
int texture_identifier = reinterpret_cast<int>(native_texture_ptr);
// auto* engine = reinterpret_cast<EmbedderEngine*>(engine_);
auto* engine = reinterpret_cast<EmbedderEngine*>(engine_);
// engine->GetShell().GetPlatformView()->RegisterTexture(
// std::make_unique<UnityExternalTextureGL>(
// texture_identifier, native_texture_ptr, surface_manager_.get()));
engine->GetShell().GetPlatformView()->RegisterTexture(
std::make_unique<UnityExternalTextureGL>(
texture_identifier));
return texture_identifier;
}

634
Samples/UIWidgetsSamples_2019_4/Assets/Scene/3DTest1.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!28 &183493893
Texture2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_IsAlphaChannelOptional: 0
serializedVersion: 3
m_Width: 0
m_Height: 0
m_CompleteImageSize: 0
m_MipsStripped: 0
m_TextureFormat: 0
m_MipCount: 1
m_IsReadable: 1
m_IsPreProcessed: 0
m_IgnoreMasterTextureLimit: 0
m_StreamingMipmaps: 0
m_StreamingMipmapsPriority: 0
m_VTOnly: 0
m_AlphaIsTransparency: 0
m_ImageCount: 0
m_TextureDimension: 2
m_TextureSettings:
serializedVersion: 2
m_FilterMode: 1
m_Aniso: 1
m_MipBias: 0
m_WrapU: 0
m_WrapV: 0
m_WrapW: 0
m_LightmapFormat: 0
m_ColorSpace: 0
m_PlatformBlob:
image data: 0
_typelessdata:
m_StreamData:
serializedVersion: 2
offset: 0
size: 0
path:
m_OriginalWidth: 0
m_OriginalHeight: 0
m_OriginalAssetGuid: 00000000000000000000000000000000
--- !u!1 &280715822
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 280715823}
- component: {fileID: 280715825}
- component: {fileID: 280715824}
m_Layer: 5
m_Name: Panel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &280715823
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 280715822}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1895879423}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &280715824
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 280715822}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d453ee00c75145f793bc44c5e68e290c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 183493893}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
devicePixelRatioEditorOnlyOverride: 0
fonts: []
--- !u!222 &280715825
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 280715822}
m_CullTransparentMesh: 1
--- !u!1 &558016097
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 558016100}
- component: {fileID: 558016099}
- component: {fileID: 558016098}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &558016098
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 558016097}
m_Enabled: 1
--- !u!20 &558016099
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 558016097}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &558016100
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 558016097}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &751999267
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 751999270}
- component: {fileID: 751999269}
- component: {fileID: 751999268}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &751999268
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 751999267}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &751999269
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 751999267}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &751999270
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 751999267}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1017590403
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1017590405}
- component: {fileID: 1017590404}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1017590404
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1017590403}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e94f297ce7d048389e796b0b290e03b6, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1017590405
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1017590403}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
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 &1465388155
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1465388157}
- component: {fileID: 1465388156}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1465388156
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1465388155}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1465388157
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1465388155}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1895879419
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1895879423}
- component: {fileID: 1895879422}
- component: {fileID: 1895879421}
- component: {fileID: 1895879420}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1895879420
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1895879419}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &1895879421
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1895879419}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!223 &1895879422
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1895879419}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &1895879423
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1895879419}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 280715823}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}

7
Samples/UIWidgetsSamples_2019_4/Assets/Scene/3DTest1.unity.meta


fileFormatVersion: 2
guid: 0f203e22a80b7fc4c93e86e2560134fd
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Samples/UIWidgetsSamples_2019_4/Assets/Resources.meta


fileFormatVersion: 2
guid: 161fa5f472b29514da5e47379e2d8ef5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

3
Samples/UIWidgetsSamples_2019_4/Assets/Script/ModelViewHelper.cs.meta


fileFormatVersion: 2
guid: e94f297ce7d048389e796b0b290e03b6
timeCreated: 1645697957

3
Samples/UIWidgetsSamples_2019_4/Assets/Script/Scene3DTest1.cs.meta


fileFormatVersion: 2
guid: d453ee00c75145f793bc44c5e68e290c
timeCreated: 1645697602

102
Samples/UIWidgetsSamples_2019_4/Assets/Script/ModelViewHelper.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using UnityEngine;
namespace UIWidgetsSample
{
public class ModelViewState
{
public RenderTexture _renderTexture;
public GameObject _modelViewPrefab;
}
public class ModelViewHelper : MonoBehaviour
{
static ModelViewHelper _instance;
public static ModelViewHelper Instance
{
get
{
if (_instance == null)
{
//ensureModelViewHelperIfNeeded();
}
return _instance;
}
}
/*internal static void ensureModelViewHelperIfNeeded() {
if (_instance != null) {
return;
}
var managerObj = new GameObject("__ModelViewHelper");
var component = managerObj.AddComponent<ModelViewHelper>();
_instance = component;
}*/
//private static bool applicationIsQuitting = false;
public void Awake()
{
if (_instance != null)
{
Debug.Log("error 11");
}
_instance = this;
}
public void OnDestroy()
{
_instance = null;
}
//private void Awake()
//{
// DontDestroyOnLoad(gameObject);
//}
public Dictionary<int, ModelViewState> modelStates = new Dictionary<int, ModelViewState>();
public void UnloadAll()
{
}
public bool Load(int id, string path)
{
if (modelStates.ContainsKey(id))
{
return true;
}
var modelViewPrefab = Resources.Load(path);
if (modelViewPrefab == null)
{
Debug.Log("Load failed !");
}
var gameObj = (GameObject) Instantiate(modelViewPrefab, Vector3.zero, Quaternion.identity);
var renderTexture = new RenderTexture(100, 100, 32);
gameObj.transform.Find("Camera").GetComponent<Camera>().targetTexture = renderTexture;
this.modelStates.Add(id, new ModelViewState
{
_renderTexture = renderTexture,
_modelViewPrefab = gameObj
});
return true;
}
public RenderTexture LoadModelViewRT(int id)
{
return this.modelStates[id]._renderTexture;
}
}
}

92
Samples/UIWidgetsSamples_2019_4/Assets/Script/Scene3DTest1.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Image = Unity.UIWidgets.widgets.Image;
using Texture = Unity.UIWidgets.widgets.Texture;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample
{
namespace UIWidgetsSample
{
public class Scene3DTest1 : UIWidgetsPanel
{
protected override void main()
{
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new ExampleApp(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context)
)
);
}
}
class ExampleApp : StatefulWidget
{
public ExampleApp(Key key = null) : base(key)
{
}
public override State createState()
{
return new ExampleState();
}
}
class ExampleState : State<ExampleApp>
{
public override Widget build(BuildContext context)
{
//var text = GameObject.Find("CameraTarget")?.GetComponent<UnityEngine.UI.RawImage>()?.texture;
ModelViewHelper.Instance?.Load(1, "CubPrefab");
var text = ModelViewHelper.Instance?.LoadModelViewRT(1);
return new Container(
child: new Column(
children: new List<Widget>
{
new Lottie("wine.json", size: new Size(100, 100)),
new Container(width: 200, height: 200, color: Colors.red, child: new Center(child: new Container(width: 100, height: 100, child:new Texture(texture: text)))),
new Container(
width: 100,
height: 100,
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Image.file("test.gif", gaplessPlayback: true)
),
new Container(
width: 200,
height: 100,
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Image.network(
"https://unity-cn-cms-prd-1254078910.cos.ap-shanghai.myqcloud.com/assetstore-cms-media/img-7dfe215f-0075-4f9c-9b5a-be5ee88b866b",
gaplessPlayback: true)
)
}
)
);
}
}
}
}
}

72
engine/src/shell/platform/unity/android/unity_external_texture_gl.cc


#include "unity_external_texture_gl.h"
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include "flutter/fml/logging.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/gl/GrGLTypes.h"
#include "src/gpu/gl/GrGLDefines.h"
#include "uiwidgets_system.h"
namespace uiwidgets {
UnityExternalTextureGL::UnityExternalTextureGL(
int64_t texture_identifier)
: Texture(texture_identifier){
auto* graphics = UIWidgetsSystem::GetInstancePtr()
->GetUnityInterfaces()
->Get<IUnityGraphics>();
UnityGfxRenderer renderer = graphics->GetRenderer();
FML_DCHECK(renderer == kUnityGfxRendererOpenGLES20 || renderer == kUnityGfxRendererOpenGLES30);
gl_texture_ = texture_identifier;
}
UnityExternalTextureGL::~UnityExternalTextureGL() {
last_image_ = nullptr;
if (gl_texture_) {
glDeleteTextures(1, &gl_texture_);
gl_texture_ = 0;
}
}
// |flutter::Texture|
void UnityExternalTextureGL::Paint(SkCanvas& canvas, const SkRect& bounds,
bool freeze, GrContext* context) {
if (!last_image_) {
GrGLTextureInfo texture_info;
texture_info.fTarget = GR_GL_TEXTURE_2D;
texture_info.fID = gl_texture_;
texture_info.fFormat = GR_GL_RGBA8;
GrBackendTexture backend_tex = GrBackendTexture(
bounds.width(), bounds.height(), GrMipMapped::kNo, texture_info);
last_image_ = SkImage::MakeFromTexture(
context, backend_tex, kBottomLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType, kOpaque_SkAlphaType, nullptr);
}
if (last_image_) {
if (bounds != SkRect::Make(last_image_->bounds())) {
canvas.drawImageRect(last_image_, bounds, nullptr);
} else {
canvas.drawImage(last_image_, bounds.x(), bounds.y());
}
}
}
// |flutter::Texture|
void UnityExternalTextureGL::OnGrContextCreated() {}
// |flutter::Texture|
void UnityExternalTextureGL::OnGrContextDestroyed() {}
// |flutter::Texture|
void UnityExternalTextureGL::MarkNewFrameAvailable() {}
// |flutter::Texture|
void UnityExternalTextureGL::OnTextureUnregistered() {}
} // namespace uiwidgets

40
engine/src/shell/platform/unity/android/unity_external_texture_gl.h


#pragma once
#include "flow/texture.h"
#include "flutter/fml/macros.h"
#include "include/core/SkImage.h"
#include "include/core/SkSize.h"
#include "unity_surface_manager.h"
namespace uiwidgets {
class UnityExternalTextureGL : public Texture {
public:
UnityExternalTextureGL(int64_t texture_identifier);
~UnityExternalTextureGL() override;
private:
GLuint gl_texture_;
sk_sp<SkImage> last_image_;
// |flutter::Texture|
void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze,
GrContext* context) override;
// |flutter::Texture|
void OnGrContextCreated() override;
// |flutter::Texture|
void OnGrContextDestroyed() override;
// |flutter::Texture|
void MarkNewFrameAvailable() override;
// |flutter::Texture|
void OnTextureUnregistered() override;
FML_DISALLOW_COPY_AND_ASSIGN(UnityExternalTextureGL);
};
} // namespace uiwidgets

7
Samples/UIWidgetsSamples_2019_4/Assets/Resources/CubPrefab.prefab.meta


fileFormatVersion: 2
guid: adca91dcd1cc06a408c4320cddda1c0e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

203
Samples/UIWidgetsSamples_2019_4/Assets/Resources/CubPrefab.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &606295237490439666
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 606295237490439667}
m_Layer: 0
m_Name: CubPrefab
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &606295237490439667
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 606295237490439666}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 606295237506465390}
- {fileID: 606295237605445244}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &606295237506465389
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 606295237506465390}
- component: {fileID: 606295237506465384}
m_Layer: 0
m_Name: Camera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &606295237506465390
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 606295237506465389}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 606295237490439667}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &606295237506465384
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 606295237506465389}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!1 &606295237605445187
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 606295237605445244}
- component: {fileID: 606295237605445247}
- component: {fileID: 606295237605445246}
- component: {fileID: 606295237605445245}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &606295237605445244
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 606295237605445187}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 2.119}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 606295237490439667}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &606295237605445247
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 606295237605445187}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &606295237605445246
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 606295237605445187}
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: 10303, guid: 0000000000000000f000000000000000, type: 0}
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!65 &606295237605445245
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 606295237605445187}
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}

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存