private bool TryLoadAsGameObject(Object obj, AssetInfo assetInfo, AbstractAssetLoadRequest req) { var go = obj as GameObject; if (go != null) { var profiler = SingletonManager.Get <LoadRequestProfileHelp>().GetProfile(assetInfo); profiler.InstantiateTimes++; var hasPosition = req.Option.Position.HasValue; var hasRotation = req.Option.Rotation.HasValue; if (hasPosition || hasRotation) { var position = hasPosition ? req.Option.Position.Value : Vector3.zero; var rotation = hasRotation ? req.Option.Rotation.Value : Quaternion.identity; obj = Object.Instantiate(go, position, rotation, GetGameObjectParent(req)); } else { obj = Object.Instantiate(go, GetGameObjectParent(req), false); } go = obj as GameObject; } var unityObj = new UnityObject(obj, assetInfo); req.LoadedObject = unityObj; if (req.AutoActive) { unityObj.SetActive(true); } if (go != null) { unityObj.WithPostProcessor(req.Option.PostProcessorFactory).OnLoadFromAsset(); if (req.Option.Recyclable) { unityObj.AddUnityObjectReference(); } var profiler = SingletonManager.Get <LoadRequestProfileHelp>().GetProfile(assetInfo); profiler.TotalInstantiateTime += profiler.StopWatch(); return(true); } return(false); }
private bool TryLoadAsGameObject(Object obj, AssetInfo assetInfo, AbstractAssetLoadRequest req) { var go = obj as GameObject; if (go != null) { var profiler = SingletonManager.Get <LoadRequestProfileHelp>().GetProfile(assetInfo); profiler.InstantiateTimes++; obj = Object.Instantiate(go, GetGameObjectParent(req), false); go = obj as GameObject; } var unityObj = new UnityObject(obj, assetInfo); req.LoadedObject = unityObj; if (req.AutoActive) { unityObj.SetActive(true); } if (go != null) { unityObj.WithPostProcessor(req.Option.PostProcessorFactory).OnLoadFromAsset(); if (req.Option.Recyclable) { unityObj.AddUnityObjectReference(); } var profiler = SingletonManager.Get <LoadRequestProfileHelp>().GetProfile(assetInfo); profiler.TotalInstantiateTime += profiler.StopWatch(); return(true); } return(false); }