本文整理汇总了C#中UnityEngine.WWW.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# WWW.Dispose方法的具体用法?C# WWW.Dispose怎么用?C# WWW.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.WWW
的用法示例。
在下文中一共展示了WWW.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadAssetBundle
public IEnumerator LoadAssetBundle()
{
state = DownloadState.Init;
downLoader = new WWW(path + fileName);
state = DownloadState.Loading;
yield return downLoader;
if(downLoader.error!=null)
{
state = DownloadState.LoadFailed;
downLoader.Dispose();
yield break;
}
else
{
size = downLoader.bytesDownloaded;
assetBundle = downLoader.assetBundle;
if(assetBundle==null)
{
state = DownloadState.LoadFailed;
}
else
{
state = DownloadState.Loaded;
}
downLoader.Dispose();
}
}
示例2: getStatusFromFinishedWWW
//throws TransportException,ApplicatonLevelException,HttpErrorCode
public WebServiceReturnStatus getStatusFromFinishedWWW(WWW www, Stopwatch sw,
ITransfluentParameters originalCallParams)
{
UnityEngine.Debug.Log("WWW:" + www.url);
var status = new WebServiceReturnStatus
{
serviceParams = originalCallParams
};
sw.Stop();
status.requestTimeTaken = sw.Elapsed;
if(!www.isDone && www.error == null)
{
throw new TransportException("Timeout total time taken:");
}
if(www.error == null)
{
status.text = www.text;
}
else
{
string error = www.error;
if(knownTransportError(error))
{
www.Dispose();
throw new TransportException(error);
}
status.httpErrorCode = -1;
int firstSpaceIndex = error.IndexOf(" ");
if(firstSpaceIndex > 0)
{
www.Dispose();
int.TryParse(error.Substring(0, firstSpaceIndex), out status.httpErrorCode);
//there has to be a better way to get error codes.
if(status.httpErrorCode == 0)
{
throw new Exception("UNHANDLED ERROR CODE FORMAT:(" + error + ")");
}
if(status.httpErrorCode >= 400 && status.httpErrorCode <= 499)
{
throw new ApplicatonLevelException("HTTP Error code, application level:" + status.httpErrorCode,
status.httpErrorCode);
}
throw new HttpErrorCode(status.httpErrorCode);
}
throw new Exception("Unknown error:" + error); //can't parse error status
}
www.Dispose();
return status;
}
示例3: Start
protected virtual IEnumerator Start()
{
Application.targetFrameRate = 30;
GlobalState.Instance.SceneToSwitchTo = Config.Scenes.None;
// Initialize all text fields and button texts.
GameObject.Find("QuestionProgressText").GetComponent<Text>().text = string.Format(StringResources.QuestionProgressText, "?", "?");
GameObject.Find("CoinProgressText").GetComponent<Text>().text = string.Format(StringResources.CoinProgressText, "?", "?");
GameObject.Find("TitleText").GetComponent<Text>().text = StringResources.MainMenuHeading;
GameObject.Find("GoButton").GetComponentInChildren<Text>().text = StringResources.GoButtonText;
GameObject.Find("HelpButton").GetComponentInChildren<Text>().text = StringResources.HelpButtonText;
// Load questions from API.
var questionsWww = new WWW(Config.ApiUrlQuestions);
// Wait for download to complete
yield return questionsWww;
// Store loaded questions in GlobalState.
GlobalState.Instance.AllQuestions = JsonUtility.FromJson<Questions>(questionsWww.text);
questionsWww.Dispose();
// Update progress texts.
GameObject.Find("QuestionProgressText").GetComponent<Text>().text = string.Format(StringResources.QuestionProgressText,
GlobalState.Instance.UnlockedCoinCount(), GlobalState.Instance.AllQuestions.questions.Length);
GameObject.Find("CoinProgressText").GetComponent<Text>().text = string.Format(StringResources.CoinProgressText,
GlobalState.Instance.CollectedCoinCount(), GlobalState.Instance.AllQuestions.questions.Length);
}
示例4: LoadTexture_YIELD
protected override IEnumerator LoadTexture_YIELD(ResourceAsyncOperation asyncOperation, IImageComponent component, ResourceBase resource) {
var filePath = resource.GetStreamPath();
var task = new WWW(filePath);
while (task.isDone == false) {
asyncOperation.SetValues(isDone: false, progress: task.progress, asset: null);
yield return false;
}
var movie = task.movie;
asyncOperation.SetValues(isDone: false, progress: 1f, asset: movie);
task.Dispose();
task = null;
System.GC.Collect();
//Debug.LogWarning("GetTexture_YIELD: " + filePath + " :: " + movie.isReadyToPlay);
while (movie.isReadyToPlay == false) {
yield return false;
}
asyncOperation.SetValues(isDone: true, progress: 1f, asset: movie);
}
示例5: getCollabEditDocument
//
public IEnumerator getCollabEditDocument()
{
var build = ResourceLoader.Load<BuildConfigSO>();
var www = new WWW(string.Format("{0}?User={1}&Platform={2}&BUILD_NUMBER={3}&BUILD_TYPE={4}",
RequestUrl, SystemInfo.deviceUniqueIdentifier, Application.platform, build.BuildNumber, build.BuildType));
yield return www;
try
{
if(string.IsNullOrEmpty(www.error))
{
output.map = www.text.JsonDeserialize<InterfaceMap>();
//output.text = www.text;
output.success = true;
}
else
{
output.error = www.error;
Debug.LogError("ERROR downloading mappings:" + www.error);
}
}
catch(Exception e)
{
output.error = "Unhandled exception:" + e;
Debug.LogError("Unhandled exception message when handling www call:" + e.Message + " stack:" + e.StackTrace);
}
finally
{
www.Dispose();
}
}
示例6: ReceiveCallback
protected override IEnumerator ReceiveCallback(WWW www, string id)
{
yield return www;
if (www.error == null)
{
string contentEncoding = string.Empty;
foreach (var kvp in www.responseHeaders)
{
if (kvp.Key.Equals(CONTENT_ENCODING, System.StringComparison.OrdinalIgnoreCase) == true)
{
contentEncoding = kvp.Key;
break;
}
}
if (string.IsNullOrEmpty(contentEncoding) == false &&
www.responseHeaders[contentEncoding].Equals(ENCODING_ENCRYPT, System.StringComparison.OrdinalIgnoreCase) == true)
{
byte[] decryptedData = AES.Decrypt(www.bytes, 0, www.bytes.Length);
if (decryptedData != null)
OnReceive(id, decryptedData, 0, decryptedData.Length);
else
OnError(id, "Decrypt fail", null);
}
else
{
OnReceive(id, www.bytes, 0, www.bytes.Length);
}
}
else
OnError(id, www.error, null);
www.Dispose();
}
示例7: Start
IEnumerator Start()
{
string url = "file://" + Application.dataPath.Substring(0, Application.dataPath.LastIndexOf('/')) + "/GameData/OLDD/DockingCam/dockingcameraassets";
while (!Caching.ready)
yield return null;
Debug.Log("AssetLoader::Start caching ready");
// Start a download of the given URL
WWW www = new WWW(url);
// Wait for download to complete
yield return www;
// Load and retrieve the AssetBundle
Debug.Log("AssetLoader:finished");
AssetBundle bundle = www.assetBundle;
matOldTV = (Material)bundle.LoadAsset("OldTV");
matNightVisionNoise1 = (Material)bundle.LoadAsset("NightVisionNoise1");
matNoise = (Material)bundle.LoadAsset("Noise");
matNoiseNightVision = (Material)bundle.LoadAsset("NoiseNightVision");
matNightVisionClear = (Material)bundle.LoadAsset("NightVisionClear");
texSelfRot = (Texture2D)bundle.LoadAsset("selfrot");
texTargetRot = (Texture2D)bundle.LoadAsset("targetrot");
texTargetPoint = (Texture2D)bundle.LoadAsset("targetPoint");
texLampOn = (Texture2D)bundle.LoadAsset("lampon");
texLampOff = (Texture2D)bundle.LoadAsset("lampoff");
texDockingCam = (Texture2D)bundle.LoadAsset("dockingcam");
Debug.Log("AssetLoader: get all materials");
www.Dispose();
}
示例8: LoadTexture
public static Texture2D LoadTexture(string path, bool repeat)
{
Texture2D texture;
WWW www = new WWW(SysPath.GetWwwPath(path));
while (!www.isDone); // FIXME: Blocks, thread this?
texture = www.texture; // Compare with www.LoadImageIntoTexture(texture)?
texture.wrapMode = (repeat) ? TextureWrapMode.Repeat : TextureWrapMode.Clamp;
texture.Compress(true);
www.Dispose();
return texture;
}
示例9: ReceiveCallback
protected override IEnumerator ReceiveCallback(WWW www, string id)
{
yield return www;
if (www.error == null)
{
string contentEncoding = string.Empty;
foreach (var kvp in www.responseHeaders)
{
if (kvp.Key.Equals(CONTENT_ENCODING, System.StringComparison.OrdinalIgnoreCase) == true)
{
contentEncoding = kvp.Key;
break;
}
}
if (string.IsNullOrEmpty(contentEncoding) == false && www.responseHeaders[contentEncoding].Equals(ENCODING_GZIP, System.StringComparison.OrdinalIgnoreCase) == true)
{
using (MemoryStream inputStream = new MemoryStream())
{
using (GZipInputStream zipStream = new GZipInputStream(new MemoryStream(www.bytes)))
{
byte[] buffer = new byte[4096];
int count = 0;
do
{
count = zipStream.Read(buffer, 0, www.bytes.Length);
inputStream.Write(buffer, 0, count);
} while (count != 0);
}
byte[] receiveData = inputStream.ToArray();
OnReceive(id, receiveData, 0, receiveData.Length);
}
}
else
{
OnReceive(id, www.bytes, 0, www.bytes.Length);
}
}
else
OnError(id, www.error, null);
www.Dispose();
}
示例10: RealLoadImage
//This is where the actual code is executed
//A URL where the image is stored
private IEnumerator RealLoadImage(string url, UnityEngine.UI.Image imageView)
{
if (imageCashe.ContainsKey (url)) {
if (imageView != null) {
imageView.sprite = imageCashe[url];
}
} else {
//Call the WWW class constructor
WWW imageURLWWW = new WWW (url);
//Wait for the download
yield return imageURLWWW;
//Simple check to see if there's indeed a texture available
if(imageURLWWW.error == null){
if (imageURLWWW.texture != null) {
//Construct a new Sprite
Sprite sprite = new Sprite ();
//Create a new sprite using the Texture2D from the url.
//Note that the 400 parameter is the width and height.
//Adjust accordingly
sprite = Sprite.Create (imageURLWWW.texture, new Rect (0, 0, imageURLWWW.texture.width, imageURLWWW.texture.height), Vector2.zero);
if(!imageCashe.ContainsKey(url))
{
imageCashe.Add (url, sprite);
}
//Assign the sprite to the Image Component
if (imageView != null) {
imageView.sprite = sprite;
}
}
}
imageURLWWW.Dispose ();
imageURLWWW = null;
}
yield return null;
}
示例11: CoLoadBundle
IEnumerator CoLoadBundle(string name, string path)
{
DebugStr = "CoLoadBundle";
using (WWW www = new WWW(path))
{
if (www == null)
{
Debugger.LogError(name + " bundle not exists");
yield break;
}
yield return www;
if (www.error != null)
{
Debugger.LogError(string.Format("Read {0} failed: {1}", path, www.error));
yield break;
}
--bundleCount;
LuaFileUtils.Instance.AddSearchBundle(name, www.assetBundle);
www.Dispose();
}
}
示例12: Process
private IEnumerator Process(WWW www)
{
yield return www;
if(www.error == null)
{
if (www.responseHeaders.ContainsKey("STATUS"))
{
//LOG Google analitic
if (www.responseHeaders["STATUS"] == "HTTP/1.1 200 OK")
{
//Debug.Log ("GA Success");
} else {
//Debug.LogWarning(www.responseHeaders["STATUS"]);
}
}else{
Debug.LogWarning("Event failed to send to Google");
}
}else{
Debug.LogWarning(www.error.ToString());
}
www.Dispose();
}
示例13: Update
private void Update()
{
if (Input.GetKey(KeyCode.LeftAlt) && Input.GetKeyDown(_keybind))
{
Toggle();
}
if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(_keybind))
{
_showList = !_showList;
}
if (_imageList == null) return;
if (_lastimg == _selectionGridInt) return;
Destroy(_image);
_imagefile = _imageList[_selectionGridInt];
_imagetex = new WWW(_imageurl + _imagefile);
_image = _imagetex.texture;
_imagetex.Dispose();
_lastimg = _selectionGridInt;
}
示例14: DownloadImage
/// <summary>
/// Downloads an image at the given URL and converts it to a Unity Texture2D.
/// </summary>
/// <param name="url">The URL of the image to download.</param>
/// <returns>The image as a Unity Texture2D object.</returns>
public static Texture2D DownloadImage(string url)
{
bool timedout = false;
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
WWW request = new WWW(url);
while (!request.isDone)
{
if (stopwatch.ElapsedMilliseconds >= 750)
{
//LogVerbose("Downloading image timed out! Took more than 750ms.");
request.Dispose();
stopwatch.Stop();
timedout = true;
break;
}
}
if (!timedout && !string.IsNullOrEmpty(request.error))
{
LogVerbose(request.error);
}
Texture2D result = null;
if (!timedout && string.IsNullOrEmpty(request.error))
{
result = request.texture;
}
return result;
}
示例15: LoadAudioClip
/// <summary>
/// Loads a base <see cref="AudioClip"/> from disk
/// </summary>
/// <returns>
/// A base <see cref="AudioClip"/>
/// </returns>
/// <param name='path'>
/// Path to audio file
/// </param>
/// <param name='stream'>
/// Whether or not the <see cref="AudioClip"/> should be fully loaded into memory or streamed from disk
/// </param>
private static AudioClip LoadAudioClip(string path, bool stream)
{
string filePath = SysPath.FindFile(path, SysPath.AudioExtensions);
if (filePath == null) {
Logger.Error(TAG, String.Format("Unable to find audio file: \"{0}\"", path));
return null;
}
string url = SysPath.GetWwwPath(filePath);
WWW www = new WWW(url);
//while (!www.isDone); // FIXME: Is blocking here necessary?
AudioClip clip;
clip = www.GetAudioClip(false, stream);
while(!clip.isReadyToPlay); // Wait for buffer
www.Dispose(); // FIXME: What does this even do? Documentation is blank...
if (clip == null) {
Logger.Error(TAG, String.Format("Unable to load audio file: \"{0}\"", url));
}
return clip;
}