unity3d中的http通信 二
转载自 http://www.cnblogs.com/88999660/archive/2013/03/11/2954279.html
如果侵权,请及时通知我删除!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
namespace UpdatePhoto
{
public partial class UpdatePhoto : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string id = Request.Form["id"];
HttpPostedFile hfc = Request.Files["Photo"];
if (hfc == null) return; Stream sm = hfc.InputStream;
byte[] buffer = new byte[sm.Length];
sm.Read(buffer, 0, buffer.Length);
sm.Close(); string path = Request.PhysicalApplicationPath + id + "\\";
//判断路径是否存在
if (!Directory.Exists(path))
{
//如果不存在就创建
Directory.CreateDirectory(path);
}
//产生文件名
string fileName = path + id + "_" + DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss") + "_" + DateTime.Now.Millisecond.ToString() + ".png";
Stream flstr = new FileStream(fileName, FileMode.Create);
BinaryWriter sw = new BinaryWriter(flstr, Encoding.Unicode);
sw.Write(buffer);
flstr.Close();
sw.Close(); }
}
}

client:

using UnityEngine;
using System.Collections; public class updatePhoto : MonoBehaviour { // Use this for initialization
void Start () {
StartCoroutine(ScreenShot());
}
IEnumerator ScreenShot(){
int width = Screen.width;
int height = Screen.height;
// string path = Application.dataPath+"/Resources/";
yield return new WaitForEndOfFrame();
Texture2D tex = new Texture2D(width,height,TextureFormat.RGB24,false);
tex.ReadPixels(new Rect(0,0,width,height),0,0);
//tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
tex.Apply();
byte[] bytes = tex.EncodeToPNG(); WWWForm newForm = new WWWForm(); newForm.AddField("id","123");
newForm.AddBinaryData("Photo",bytes,"photo.jpg"); WWW w = new WWW("http://localhost:36944/UpdatePhoto.aspx", newForm); while (!w.isDone){yield return new WaitForEndOfFrame();} if (w.error != null){Debug.LogError(w.error);}
} }
unity3d中的http通信 二的更多相关文章
- unity3d中的http通信
转载 http://blog.csdn.net/mfc11/article/details/8188785的博客,如果侵权,请留言我及时删除! 前言 Unity3d 是一个跨平台的引擎,在移动互联网浪 ...
- 【Unity3D基础教程】给初学者看的Unity教程(五):详解Unity3D中的协程(Coroutine)
作者:王选易,出处:http://www.cnblogs.com/neverdie/ 欢迎转载,也请保留这段声明.如果你喜欢这篇文章,请点[推荐].谢谢! 为什么需要协程 在游戏中有许多过程(Proc ...
- MVVM模式和在WPF中的实现(二)数据绑定
MVVM模式解析和在WPF中的实现(二) 数据绑定 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在WPF中 ...
- 【Unity3d游戏开发】Unity3D中的3D数学基础---向量
向量是2D.3D数学研究的标准工具,在3D游戏中向量是基础.因此掌握好向量的一些基本概念以及属性和常用运算方法就显得尤为重要.在本篇博客中,马三就来和大家一起回顾和学习一下Unity3D中那些常用的3 ...
- unity3d中 刚体(Rigidbody) 碰撞体(Collider) 触发器(Is Trigger)
刚体(Rigidbody)的官方(摘自Unity3d的官方指导书<Unity4.x从入门到精通>)解释如下: Rigidbody(刚体)组件可使游戏对象在物理系统的控制下来运动,刚体可 ...
- 转 猫都能学会的Unity3D Shader入门指南(二)
猫都能学会的Unity3D Shader入门指南(二) 关于本系列 这是Unity3D Shader入门指南系列的第二篇,本系列面向的对象是新接触Shader开发的Unity3D使用者,因为我本身自己 ...
- Unity3D中Ragdoll的用法
一.创建Ragdoll 见unity3d组件文档里的Ragdoll Wizard.由于unity3d中的Ragdoll设置的骨骼点名字与3DMAX里人体骨骼命名有些不一样,下图为Unity3 ...
- STUN/TURN/ICE协议在P2P SIP中的应用(二)
1 说明 2 打洞和穿越的概念... 1 3 P2P中的打洞和穿越... 2 4 使用STUN系列 协议穿越的特点... 2 5 STUN/ ...
- Unity3D中的Coroutine详解
Unity中的coroutine是通过yield expression;来实现的.官方脚本中到处会看到这样的代码. 疑问: yield是什么? Coroutine是什么? unity的coroutin ...
随机推荐
- mysqldump 定时任务 执行后备份的文件为空
#!/bin/bash mysql_host="127.0.0.1" mysql_user="root" mysql_passwd="******** ...
- iOS进度指示器——NSProgress
iOS进度指示器——NSProgress 一.引言 在iOS7之前,系统一直没有提供一个完整的框架来描述任务进度相关的功能.这使得在开发中进行耗时任务进度的监听将什么麻烦,在iOS7之后,系统提供了N ...
- hadoop集群环境搭建之zookeeper集群的安装部署
关于hadoop集群搭建有一些准备工作要做,具体请参照hadoop集群环境搭建准备工作 (我成功的按照这个步骤部署成功了,经实际验证,该方法可行) 一.安装zookeeper 1 将zookeeper ...
- 实用脚本 - - addLoadEvent 页面加载完毕执行函数
function addLoadEvent(func){ var oldonload = window.onload; if(typeof window.onload != "functio ...
- 什么是html,什么是php
学了这么长时间的网站建设,好像对这两个概念说以来还是语无伦次的,所以就来写一写了.html是什么呢,官方解释:超文本标记语言,超文本就是指页面可以包含图片,连接等非文字元素.超文本标记语言也是一种规范 ...
- Linux试玩指令开机关机
Linux内核最初只是由芬兰人李纳斯·托瓦兹(Linus Torvalds)在赫尔辛基大学上学时出于个人爱好而编写的. Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和U ...
- 自定义图文混排视图MyImageTextView
http://blog.csdn.net/xujunfeng000/article/details/36399339?utm_source=tuicool&utm_medium=referra ...
- 完全卸载oracle
今天在网上看到有位网友写的篇日志,感觉蛮好的,一般卸载oracle有4个地方需求注意:1)Services,2)software,3eventlog,4)path. 1.关闭 oracle 所有的服务 ...
- Simple screenshot that explains the non-static invocation.
Here is the code: /* Instance invocation in the memory: */ package kju.obj; import static kju.print. ...
- iis6 下发布MVC2项目的方法
1.安装MVC2运行库,否则会出现错误 [以下转载]http://blog.csdn.net/xw13106209/article/details/6323695 错误:”未能加载文件或程序集“Sys ...