Exemplo n.º 1
0
        public static bool TryGetGUIDAndLocalFileIdentifier <T>(LazyLoadReference <T> assetRef, out string guid, out long localId) where T : UnityEngine.Object
        {
            GUID uguid;
            bool res = GetGUIDAndLocalIdentifierInFile(assetRef.instanceID, out uguid, out localId);

            guid = uguid.ToString();
            return(res);
        }
Exemplo n.º 2
0
 public static int GetInstanceId <T>(this LazyLoadReference <T> lazy) where T : Object
 {
     #if UNITY_2020_1_OR_NEWER
     return(lazy.instanceID);
     #else
     var field = lazy.GetType().GetField("m_InstanceID", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
     return((int)field.GetValue(lazy));
     #endif
 }
Exemplo n.º 3
0
        public void ChangeDocumentTheme(VisualElement documentElement, CanvasTheme canvasTheme, ThemeStyleSheet themeSheet)
        {
            m_CurrentCanvasTheme = canvasTheme;
            m_CurrentCanvasThemeStyleSheetReference = themeSheet;

            if (themeSheet)
            {
                themeSheet.isDefaultStyleSheet = true;
            }
            RefreshStyle(documentElement);
        }
Exemplo n.º 4
0
        public void GetBuildPipeline_IsEqualToPipeline()
        {
            var pipeline = BuildPipeline.CreateInstance();
            var config   = BuildConfiguration.CreateInstance(c => c.SetComponent(new TestPipelineComponent
            {
#if UNITY_2020_1_OR_NEWER
                Pipeline = new LazyLoadReference <BuildPipeline> {
                    instanceID = pipeline.GetInstanceID()
                }
#else
                Pipeline = pipeline
#endif
            }));
        /// <summary>
        /// Test build case where Editor target switch is required
        /// Note: Currently we can only effectively test this on Windows, because we have there 32 & 64 bit targets, thus we'll need target switch.
        ///       On OSX, there's only 64 bit target, so no real target switch will be required
        /// </summary>
        /// <returns></returns>

        // Disable for now, this test seems to affect tests which are ran after , for ex.,
        //        VerifyNoCompilerErrors(0.005s) from com.unity.platforms.desktop\Tests\Editor\BasicTests.cs
        //---
        //System.Reflection.TargetException : Non-static method requires a target.
        //---
        //at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)[0x0004c] in <437ba245d8404784b9fbab9b439ac908>:0
        //  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters)[0x00000] in <437ba245d8404784b9fbab9b439ac908>:0
        //  at NUnit.Framework.Internal.Reflect.InvokeMethod (System.Reflection.MethodInfo method, System.Object fixture, System.Object[] args)[0x0005e] in <59819be142c34115ade688f6962021f1>:0
        // https://fogbugz.unity3d.com/f/cases/1205240/
        // [UnityTest]
        public IEnumerator CanBuildMultipleBuildsWithActiveTargetSwitch()
        {
            m_BuildPipeline = BuildPipeline.CreateAsset(k_TestBuildBuildpipelineAssetPath,
                                                        (p) =>
            {
                p.BuildSteps.Add(new TestBuildStepSuccess());
            });

            m_SettingsWindows32 = BuildConfiguration.CreateAsset(k_TestBuildConfiguration32AssetPath, (bs) =>
            {
                bs.SetComponent(new FakeClassicBuildProfile()
                {
                    Target = Standalone32Target,
#if UNITY_2020_1_OR_NEWER
                    Pipeline = new LazyLoadReference <BuildPipeline> {
                        instanceID = m_BuildPipeline.GetInstanceID()
                    }
#else
                    Pipeline = m_BuildPipeline
#endif
                });
Exemplo n.º 6
0
        public override VisualElement Build()
        {
            var lazyLoadReferenceField = Resources.Templates.LazyLoadReference.Clone();

            var labelElement = lazyLoadReferenceField.Q <Label>("label");

            labelElement.text = DisplayName;

            m_ObjectField            = lazyLoadReferenceField.Q <ObjectField>("input");
            m_ObjectField.objectType = typeof(T);
            m_ObjectField.value      = Target.asset;
            m_ObjectField.RegisterValueChangedCallback(changeEvent =>
            {
                Target = new LazyLoadReference <T> {
                    asset = (T)changeEvent.newValue
                };
                NotifyChanged();
            });

            return(lazyLoadReferenceField);
        }
Exemplo n.º 7
0
        public void LazyLoadReference_WhenRootIsTexture2DAsset_CanBeSerializedAndDeserialized()
        {
            var image = new Texture2D(1, 1);

            AssetDatabase.CreateAsset(image, kTexture2DPath);
            AssetDatabase.ImportAsset(kTexture2DPath, ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);

            var lazyLoadReference = new LazyLoadReference <Texture2D> {
                asset = image
            };

            try
            {
                var dst = SerializeAndDeserialize(lazyLoadReference);
                Assert.That(dst, Is.EqualTo(lazyLoadReference));
            }
            finally
            {
                AssetDatabase.DeleteAsset(kTexture2DPath);
            }
        }
 public static bool TryGetGUIDAndLocalFileIdentifier <T>(LazyLoadReference <T> assetRef, out string guid, out long localId) where T : UnityEngine.Object
 {
     return(TryGetGUIDAndLocalFileIdentifier(assetRef.instanceID, out guid, out localId));
 }