Files
Magical-Jumping-Bean/Library/metadata/e8/e88a766c2b8b47841936c136f4afbba9
T

203 lines
12 KiB
Plaintext
Raw Normal View History

2019-09-29 19:40:54 -04:00
í.`2019.2.3f1þÿÿÿÿÿ’3$øÌuñ옲e+ Í=^7€ÿÿÿÿ¦€²Ð¦¦¦€#¦€+H€3ÿÿÿÿ1€1€ÿÿÿÿ@Þ Q€j
H€<ÿÿÿÿ 1€1€ÿÿÿÿ @Þ
Q€jÕ€Iÿÿÿÿ1€1€ÿÿÿÿÀÞH€j€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€j€PAssetMetaDataguiddata[0]data[1]data[2]data[3]pathNameoriginalNamelabelsassetStoreRef ÿÿfš†!ë5˜9Ý4QÁóBí7€ÿÿÿÿ¦€²
E Þ€#.€,5a Þ€#.€,€r Þ€# .€,
H€«€ÿÿÿÿ 1€1€ÿÿÿÿ @Þ
Q€jñ€JÿÿÿÿÀ1€1€ÿÿÿÿÞ€j€ÿÿÿÿ\€ÿÿÿÿH€rÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jH€wÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jH€€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jy
 Þ€#!.€,"€…ÿÿÿÿ#@1€1€ÿÿÿÿ$Þ%.€j&Õ€“ÿÿÿÿ'1€1€ÿÿÿÿ(ÀÞ)€j€ÿÿÿÿ*H€›€ÿÿÿÿ+1€1€ÿÿÿÿ,@Þ-Q€j.y
 /Þ€#0.€,1 €§2@¾€¶ 3@Þ€#4.€,5H€»ÿÿÿÿ61€1€ÿÿÿÿ7@Þ8Q€j9H€Æÿÿÿÿ:1€1€ÿÿÿÿ;@Þ<Q€j=H€Øÿÿÿÿ>1€1€ÿÿÿÿ?@Þ@Q€jAMonoImporterPPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_ExternalObjectsSourceAssetIdentifiertypeassemblynamem_UsedFileIDsm_DefaultReferencesexecutionOrdericonm_UserDatam_AssetBundleNamem_AssetBundleVariantsÿÿ£Gñ×ÜZ56 :!@iÁJ*€7€ÿÿÿÿ¦€²E Þ.(a Þ.€r Þ .
H€«€ÿÿÿÿ 1€1€ÿÿÿÿ @Þ
Q€jH€ê€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jñ€=ÿÿÿÿ1€1€ÿÿÿÿÞ€j€ÿÿÿÿH€›€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jy
 Þ.y€Q Þ. Þ€X!H€iÿÿÿÿ"1€1€ÿÿÿÿ#@Þ$Q€j%H€uÿÿÿÿ&1€1€ÿÿÿÿ'@Þ(Q€j)PPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_DefaultReferencesm_Iconm_ExecutionOrderm_ClassNamem_Namespacehh\ày¯ÈˆލgƲ¸tHccOú»š=Packages/com.unity.ugui/Tests/Runtime/Graphic/GraphicTests.csày¯ GraphicTestsusing System.Collections.Generic;
using System.IO;
using NUnit.Framework;
using UnityEditor;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.TestTools;
using UnityEngine.UI;
using UnityEngine.UI.Tests;
namespace Graphics
{
class GraphicTests : IPrebuildSetup
{
private GameObject m_PrefabRoot;
private ConcreteGraphic m_graphic;
private Canvas m_canvas;
const string kPrefabPath = "Assets/Resources/GraphicTestsPrefab.prefab";
bool m_dirtyVert;
bool m_dirtyLayout;
bool m_dirtyMaterial;
public void Setup()
{
#if UNITY_EDITOR
var rootGO = new GameObject("rootGo");
var canvasGO = new GameObject("CanvasRoot", typeof(Canvas), typeof(GraphicRaycaster));
canvasGO.transform.SetParent(rootGO.transform);
var graphicGO = new GameObject("Graphic", typeof(RectTransform), typeof(ConcreteGraphic));
graphicGO.transform.SetParent(canvasGO.transform);
var gameObject = new GameObject("EventSystem", typeof(EventSystem));
gameObject.transform.SetParent(rootGO.transform);
if (!Directory.Exists("Assets/Resources/"))
Directory.CreateDirectory("Assets/Resources/");
PrefabUtility.SaveAsPrefabAsset(rootGO, kPrefabPath);
GameObject.DestroyImmediate(rootGO);
#endif
}
[SetUp]
public void TestSetup()
{
m_PrefabRoot = Object.Instantiate(Resources.Load("GraphicTestsPrefab")) as GameObject;
m_canvas = m_PrefabRoot.GetComponentInChildren<Canvas>();
m_graphic = m_PrefabRoot.GetComponentInChildren<ConcreteGraphic>();
m_graphic.RegisterDirtyVerticesCallback(() => m_dirtyVert = true);
m_graphic.RegisterDirtyLayoutCallback(() => m_dirtyLayout = true);
m_graphic.RegisterDirtyMaterialCallback(() => m_dirtyMaterial = true);
ResetDirtyFlags();
}
[TearDown]
public void TearDown()
{
m_graphic = null;
m_canvas = null;
GameObject.Destroy(m_PrefabRoot);
}
private void ResetDirtyFlags()
{
m_dirtyVert = m_dirtyLayout = m_dirtyMaterial = false;
}
[Test]
public void SettingDirtyOnActiveGraphicCallsCallbacks()
{
m_graphic.enabled = false;
m_graphic.enabled = true;
m_graphic.SetAllDirty();
Assert.True(m_dirtyVert, "Vertices have not been dirtied");
Assert.True(m_dirtyLayout, "Layout has not been dirtied");
Assert.True(m_dirtyMaterial, "Material has not been dirtied");
ResetDirtyFlags();
m_graphic.SetLayoutDirty();
Assert.True(m_dirtyLayout, "Layout has not been dirtied");
m_graphic.SetVerticesDirty();
Assert.True(m_dirtyVert, "Vertices have not been dirtied");
m_graphic.SetMaterialDirty();
Assert.True(m_dirtyMaterial, "Material has not been dirtied");
}
private bool ContainsGraphic(IList<Graphic> array, int size, Graphic element)
{
for (int i = 0; i < size; ++i)
{
if (array[i] == element)
return true;
}
return false;
}
private void RefreshGraphicByRaycast()
{
// force refresh by raycast
List<RaycastResult> raycastResultCache = new List<RaycastResult>();
PointerEventData data = new PointerEventData(EventSystem.current);
var raycaster = m_canvas.GetComponent<GraphicRaycaster>();
raycaster.Raycast(data, raycastResultCache);
}
private bool CheckGraphicAddedToGraphicRaycaster()
{
// check that Graphic is removed from m_CanvasGraphics
var raycaster = m_canvas.GetComponent<GraphicRaycaster>();
var graphicList = GraphicRegistry.GetGraphicsForCanvas(m_canvas);
var graphicListSize = graphicList.Count;
return ContainsGraphic(graphicList, graphicListSize, m_graphic);
}
private void CheckGraphicRaycastDisableValidity()
{
RefreshGraphicByRaycast();
Assert.False(CheckGraphicAddedToGraphicRaycaster(), "Graphic should no longer be registered in m_CanvasGraphics");
}
[Test]
public void OnEnableLeavesGraphicInExpectedState()
{
m_graphic.enabled = false;
m_graphic.enabled = true; // on enable is called directly
Assert.True(CheckGraphicAddedToGraphicRaycaster(), "Graphic should be registered in m_CanvasGraphics");
Assert.AreEqual(Texture2D.whiteTexture, m_graphic.mainTexture, "mainTexture should be Texture2D.whiteTexture");
Assert.NotNull(m_graphic.canvas);
Assert.True(m_dirtyVert, "Vertices have not been dirtied");
Assert.True(m_dirtyLayout, "Layout has not been dirtied");
Assert.True(m_dirtyMaterial, "Material has not been dirtied");
}
[Test]
public void OnEnableTwiceLeavesGraphicInExpectedState()
{
m_graphic.enabled = true;
// force onEnable by reflection to call it second time
m_graphic.InvokeOnEnable();
m_graphic.enabled = false;
CheckGraphicRaycastDisableValidity();
}
[Test]
public void OnDisableLeavesGraphicInExpectedState()
{
m_graphic.enabled = true;
m_graphic.enabled = false;
CheckGraphicRaycastDisableValidity();
}
[Test]
public void OnPopulateMeshWorksAsExpected()
{
m_graphic.rectTransform.anchoredPosition = new Vector2(100, 100);
m_graphic.rectTransform.sizeDelta = new Vector2(150, 742);
m_graphic.color = new Color(50, 100, 150, 200);
VertexHelper vh = new VertexHelper();
m_graphic.InvokeOnPopulateMesh(vh);
GraphicTestHelper.TestOnPopulateMeshDefaultBehavior(m_graphic, vh);
}
[Test]
public void OnDidApplyAnimationPropertiesSetsAllDirty()
{
m_graphic.enabled = true; // Usually set through SetEnabled, from Behavior
m_graphic.InvokeOnDidApplyAnimationProperties();
Assert.True(m_dirtyVert, "Vertices have not been dirtied");
Assert.True(m_dirtyLayout, "Layout has not been dirtied");
Assert.True(m_dirtyMaterial, "Material has not been dirtied");