浏览代码

Merge branch 'master' of gitlab.cds.internal.unity3d.com:upm-packages/ui-widgets/com.unity.uiwidgets into material

/main
xingwei.zhu 6 年前
当前提交
d42a7747
共有 6 个文件被更改,包括 54 次插入39 次删除
  1. 62
      Editor/editor/EditorUtils.cs
  2. 6
      Runtime/engine/DisplayMetrics.cs
  3. 4
      Runtime/ui/geometry.cs
  4. 6
      Runtime/ui/painting/canvas_impl.cs
  5. 4
      Runtime/ui/painting/canvas_shader.cs
  6. 11
      Runtime/widgets/framework.cs

62
Editor/editor/EditorUtils.cs


namespace Unity.UIWidgets.Editor {
[InitializeOnLoad]
public class EitorUtils {
static EitorUtils() {
public class EditorUtils {
static EditorUtils() {
DisplayMetricsProvider.provider = () => new EditorPlayerDisplayMetrics();
}
}

float _lastDevicePixelRatio = 0;
public void OnGUI() {
}
public void OnGUI() {
}
public void Update() {
this._lastDevicePixelRatio = GameViewUtil.getGameViewDevicePixelRatio();
public void Update() {
this._lastDevicePixelRatio = GameViewUtil.getGameViewDevicePixelRatio();
}
public float DevicePixelRatio {

internal static class GameViewUtil {
static class GameViewUtil {
public static float getGameViewDevicePixelRatio(float fallback = 1) {
public static float getGameViewDevicePixelRatio(float fallback = 1) {
loadTypeIfNeed();
EditorWindow gameview = getMainGameView();

}
return fallback;
}
}
static EditorWindow getMainGameView() {
IEnumerable enumerable = null;
if (!getFieldValue(null, "s_GameViews", ref enumerable)) {
return null;
}
IEnumerator enumerator = enumerable != null ? enumerable.GetEnumerator() : null;
if (enumerator != null && enumerator.MoveNext()) {
return enumerator.Current as EditorWindow;
}
return null;
}
static EditorWindow getMainGameView() {
IEnumerable enumerable = null;
if (!getFieldValue(null, "s_GameViews", ref enumerable)) {
return null;
}
IEnumerator enumerator = enumerable != null ? enumerable.GetEnumerator() : null;
if (enumerator != null && enumerator.MoveNext()) {
return enumerator.Current as EditorWindow;
}
return null;
}
| BindingFlags.NonPublic
| BindingFlags.Static | BindingFlags.Instance);
| BindingFlags.NonPublic
| BindingFlags.Static | BindingFlags.Instance);
result = (T)fieldInfo.GetValue(ins);
result = (T) fieldInfo.GetValue(ins);
return true;
}

}
}
}
var property = _gameViewType.GetProperty(name, BindingFlags.Public
| BindingFlags.NonPublic |
BindingFlags.Static | BindingFlags.Instance);
var property = _gameViewType.GetProperty(name,
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Static | BindingFlags.Instance);
if (property == null) {
return false;
}

6
Runtime/engine/DisplayMetrics.cs


}
#if UNITY_ANDROID
_devicePixelRatio = AndroidDevicePixelRatio();
this._devicePixelRatio = AndroidDevicePixelRatio();
_devicePixelRatio = UIWidgetsWebGLDevicePixelRatio();
this._devicePixelRatio = UIWidgetsWebGLDevicePixelRatio();
_devicePixelRatio = IOSDeviceScaleFactor();
this._devicePixelRatio = IOSDeviceScaleFactor();
#endif
if (this._devicePixelRatio <= 0) {

4
Runtime/ui/geometry.cs


this._dy = _dy;
}
public readonly float _dx;
protected readonly float _dx;
public readonly float _dy;
protected readonly float _dy;
public bool isInfinite {
get { return float.IsInfinity(this._dx) || float.IsInfinity(this._dy); }

6
Runtime/ui/painting/canvas_impl.cs


width = textureWidth,
height = textureHeight,
layerBounds = maskBounds,
filterMode = FilterMode.Bilinear,
};
parentLayer.layers.Add(maskLayer);

width = textureWidth,
height = textureHeight,
layerBounds = maskLayer.layerBounds,
filterMode = FilterMode.Bilinear,
};
parentLayer.layers.Add(blurXLayer);

width = textureWidth,
height = textureHeight,
layerBounds = maskLayer.layerBounds,
filterMode = FilterMode.Bilinear,
};
parentLayer.layers.Add(blurYLayer);

desc.msaaSamples = QualitySettings.antiAliasing;
}
cmdBuf.GetTemporaryRT(subLayer.rtID, desc, FilterMode.Bilinear);
cmdBuf.GetTemporaryRT(subLayer.rtID, desc, subLayer.filterMode);
this._drawLayer(subLayer, cmdBuf);
}

public int rtID;
public int width;
public int height;
public FilterMode filterMode = FilterMode.Point;
public Rect layerBounds;
public Paint layerPaint;
public readonly List<object> draws = new List<object>();

4
Runtime/ui/painting/canvas_shader.cs


var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);
_getShaderPassAndProps(viewport, ctm, paint, 1.0f, out var pass, out var props);
image.texture.filterMode = paint.filterMode;
props.SetTexture("_tex", image.texture);
props.SetInt("_texMode", image.texture is RenderTexture ? 1 : 0); // pre alpha if RT else post alpha

MeshMesh mesh, PictureFlusher.RenderLayer renderLayer) {
Vector4 viewport = layer.viewport;
Matrix3 ctm = layer.states[layer.states.Count - 1].matrix;
var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);
_getShaderPassAndProps(viewport, ctm, paint, 1.0f, out var pass, out var props);

var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);
_getShaderPassAndProps(viewport, ctm, paint, 1.0f, out var pass, out var props);
tex.filterMode = paint.filterMode;
props.SetTexture("_tex", tex);
props.SetInt("_texMode", 2); // alpha only

11
Runtime/widgets/framework.cs


return true;
});
if (Window.hasInstance) {
this._setState(fn);
} else {
using (WindowProvider.of(this.context).getScope()) {
this._setState(fn);
}
}
}
void _setState(VoidCallback fn = null) {
this._element.markNeedsBuild();
}

正在加载...
取消
保存