关于unishare。按钮设置
来源:互联网 发布:linux mmap 编辑:程序博客网 时间:2024/06/05 12:10
using UnityEngine;
using System.Collections;
using System.IO;
using System;
using UniShare;
public class FuntionalButton : MonoBehaviour {
public FuncButton funcType;
public GameObject photoAfter;
public GameObject photoButton;
public GameObject achor;
public GameObject k_center;
Vector3 orgin = new Vector3(106, 106, 106);
Vector3 orgin_shu = new Vector3(53, 53, 53);
static bool sendWeibo = false;
string weiboContent = "我在华宁弘基哦";
// Use this for initialization
void Start () {
SinaWeibo.instance.OnOauthCallBack += oauthCallback;
SinaWeibo.instance.appKey = "2486190234";
SinaWeibo.instance.appSecret = "58c64af48a9e94bb4768a0d29c44f617";
SinaWeibo.instance.callbackUrl = "https://api.weibo.com/oauth2/default.html";
}
// Update is called once per frame
void Update () {
}
void OnClick()
{
if (funcType == FuncButton.Share)
{
Share();
Back();
}
else if (funcType == FuncButton.Save)
{
Save();
Back();
}
else if (funcType == FuncButton.Back)
{
Back();
}
}
void Share()
{
sendWeibo = false;
if (!SinaWeibo.instance.IsBinded)
{
SinaWeibo.instance.Authorize();
}
else
{
SendSinaWeibo();
}
}
void Save()
{
if (Application.platform == RuntimePlatform.Android)
{
CopyPhoto(false);
}
}
void Back()
{
photoAfter.SetActive(false);
photoButton.SetActive(true);
achor.SetActive(true);
k_center.SetActive(true);
photoButton.transform.localScale = orgin;
Screen.orientation = ScreenOrientation.AutoRotation;
}
void CopyPhoto(bool isWeibo)
{
try
{
if (!Directory.Exists("/sdcard/DCIM/Camera"))
Directory.CreateDirectory("/sdcard/DCIM/Camera");
string filename = "/sdcard/Android/data/com.ileou.myqcaractivity/files/photo_" + TakePhoto.number.ToString() + ".png";
string desFilename = "/sdcard/DCIM/Camera/photo_" + TakePhoto.number.ToString() + ".png";
if (File.Exists(filename))
{
File.Copy(filename, desFilename, true);
RefreshPicture(isWeibo);
}
}
catch (Exception e)
{
Debug.LogException(e);
}
}
void RefreshPicture(bool isWeibo)
{
using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
using (AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"))
{
jo.Call("refreshPicture", "photo_" + TakePhoto.number.ToString() + ".png", isWeibo);
}
}
}
void SendSinaWeibo()
{
if (sendWeibo == false)
{
sendWeibo = true;
string filename = "/sdcard/Android/data/com.ileou.myqcaractivity/files/photo_" + TakePhoto.number.ToString() + ".png";
if (File.Exists(filename))
{
SinaWeibo.instance.ShareWithImage(weiboContent, filename);
CopyPhoto(true);
}
else
{
SinaWeibo.instance.Share(weiboContent);
}
}
}
void oauthCallback(PlatformType pType, bool success)
{
if (success)
{
SendSinaWeibo();
}
}
}
public enum FuncButton
{
Share = 0,
Save,
Back
}
using System.Collections;
using System.IO;
using System;
using UniShare;
public class FuntionalButton : MonoBehaviour {
public FuncButton funcType;
public GameObject photoAfter;
public GameObject photoButton;
public GameObject achor;
public GameObject k_center;
Vector3 orgin = new Vector3(106, 106, 106);
Vector3 orgin_shu = new Vector3(53, 53, 53);
static bool sendWeibo = false;
string weiboContent = "我在华宁弘基哦";
// Use this for initialization
void Start () {
SinaWeibo.instance.OnOauthCallBack += oauthCallback;
SinaWeibo.instance.appKey = "2486190234";
SinaWeibo.instance.appSecret = "58c64af48a9e94bb4768a0d29c44f617";
SinaWeibo.instance.callbackUrl = "https://api.weibo.com/oauth2/default.html";
}
// Update is called once per frame
void Update () {
}
void OnClick()
{
if (funcType == FuncButton.Share)
{
Share();
Back();
}
else if (funcType == FuncButton.Save)
{
Save();
Back();
}
else if (funcType == FuncButton.Back)
{
Back();
}
}
void Share()
{
sendWeibo = false;
if (!SinaWeibo.instance.IsBinded)
{
SinaWeibo.instance.Authorize();
}
else
{
SendSinaWeibo();
}
}
void Save()
{
if (Application.platform == RuntimePlatform.Android)
{
CopyPhoto(false);
}
}
void Back()
{
photoAfter.SetActive(false);
photoButton.SetActive(true);
achor.SetActive(true);
k_center.SetActive(true);
photoButton.transform.localScale = orgin;
Screen.orientation = ScreenOrientation.AutoRotation;
}
void CopyPhoto(bool isWeibo)
{
try
{
if (!Directory.Exists("/sdcard/DCIM/Camera"))
Directory.CreateDirectory("/sdcard/DCIM/Camera");
string filename = "/sdcard/Android/data/com.ileou.myqcaractivity/files/photo_" + TakePhoto.number.ToString() + ".png";
string desFilename = "/sdcard/DCIM/Camera/photo_" + TakePhoto.number.ToString() + ".png";
if (File.Exists(filename))
{
File.Copy(filename, desFilename, true);
RefreshPicture(isWeibo);
}
}
catch (Exception e)
{
Debug.LogException(e);
}
}
void RefreshPicture(bool isWeibo)
{
using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
using (AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"))
{
jo.Call("refreshPicture", "photo_" + TakePhoto.number.ToString() + ".png", isWeibo);
}
}
}
void SendSinaWeibo()
{
if (sendWeibo == false)
{
sendWeibo = true;
string filename = "/sdcard/Android/data/com.ileou.myqcaractivity/files/photo_" + TakePhoto.number.ToString() + ".png";
if (File.Exists(filename))
{
SinaWeibo.instance.ShareWithImage(weiboContent, filename);
CopyPhoto(true);
}
else
{
SinaWeibo.instance.Share(weiboContent);
}
}
}
void oauthCallback(PlatformType pType, bool success)
{
if (success)
{
SendSinaWeibo();
}
}
}
public enum FuncButton
{
Share = 0,
Save,
Back
}
0 0
- 关于unishare。按钮设置
- 关于按钮设置属性的小细节
- 关于tabbar上自定义按钮的设置
- mfc关于CButtonST按钮设置不可用时,按钮变灰
- 关于CButtonST按钮设置不可用时设置按钮图标
- 按钮设置
- 关于简单的回退按钮的设置...
- 关于button按钮设置padding失效的原因
- 关于按钮layout_gravity设置为right不管用的问题
- 关于返回按钮的重载,即返回按钮的退出设置
- 关于返回按钮的重载,即返回按钮的退出设置
- 关于VC单选按钮不能设置变量的问题以及Group属性的设置
- 关于VC单选按钮不能设置变量的问题以及Group属性的设置
- 关于VC单选按钮不能设置变量以及Group属性的设置问题
- 界面设置按钮菜单设置
- 默认按钮的设置
- 如何设置默认按钮
- 设置图标按钮
- Tab效果之Tabhost
- Oracle学习(五):多表查询
- 大一软件专业实训报告
- 为Linux内核打ARM补丁
- 重建二叉树
- 关于unishare。按钮设置
- 发的回复的好的方法和
- 远程管理 Remote Management
- 数据结构->树:树的深度与高度
- ECMA 操作符
- sublime编辑器如何快速输入PHP头部版本声明
- 模型的操作
- 在VFP报表中实现每页打印指定记录数
- 使用TinyXml库值得注意的几个地方