コード例 #1
0
    /// <summary>
    /// 打开相册相机后的从ios回调到unity的方法
    /// </summary>
    /// <param name="base64">Base64.</param>
    void PickImageCallBack_Base64(string base64)
    {
//		if(CallBack_PickImage_With_Base64!=null)
//		{
//			CallBack_PickImage_With_Base64(base64);
//		}
        Texture2D tex = IOSAlbumCamera.Base64StringToTexture2D(base64);

//		string warningStr = "当前相册截图是否存在~~~" + (tex != null).ToString () + "纹理输出:" + tex.ToString ();
//		Client.MessageHint.Show (warningStr);
        //Console.Error.WriteLine ("当前相册截图的纹理集合:"+(tex==null).ToString()+"纹理输出:"+tex.ToString());

        if (null != tex)
        {
            //HttpRequestManager.GetInstance ().UpLoadImage (tex);

            if (null != img_selecthead)
            {
                Sprite m_sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0));
                img_selecthead.sprite = m_sprite;
            }
        }
        else
        {
            Client.MessageHint.Show("获取纹理集失败");
        }


//		img_selecthead.texture = tex;
    }
コード例 #2
0
ファイル: Demo.cs プロジェクト: c30gcrk/ios_photo
        IEnumerator SaveToPhoto(string imgPath)
        {
            yield return(new WaitForEndOfFrame());

            Texture2D screenImage = new Texture2D(Screen.width, Screen.height);

            //Get Image from screen
            screenImage.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
            screenImage.Apply();
            //Convert to png
            byte[] imageBytes = screenImage.EncodeToPNG();
            //Save image to file
            File.WriteAllBytes(imgPath, imageBytes);

            //给个截屏效果
            Color tempC = img.color;

            tempC.a   = 0;
            img.color = tempC;
            yield return(new WaitForSeconds(0.15f));

            tempC.a   = 1;
            img.color = tempC;

            IOSAlbumCamera.iosSaveImageToPhotosAlbum(imgPath);
        }
コード例 #3
0
ファイル: IOSPhoto.cs プロジェクト: qyadmin/RaisePigLarge
    //void onclick_saveToAlbum()
    //{
    //	string path = Application.persistentDataPath + "/lzhscreenshot.png";
    //	Debug.Log (path);

    //	byte[] bytes = (rawImage.texture as Texture2D).EncodeToPNG ();
    //	System.IO.File.WriteAllBytes (path, bytes);

    //	IOSAlbumCamera.iosSaveImageToPhotosAlbum (path);

    //}

    void callback_PickImage_With_Base64(string base64)
    {
        Texture2D tex = IOSAlbumCamera.Base64StringToTexture2D(base64);

        androidPhoto.SendPictureByTypeId(tex);
        // LoadImage.GetLoadIamge.SendImage(tex);
    }
コード例 #4
0
    void callback_PickImage_With_Base64(string base64)
    {
        Texture2D tex = IOSAlbumCamera.Base64StringToTexture2D(base64);

        rawImage.texture = tex;
        ri.TestHttpSend(base64);
    }
コード例 #5
0
 void Awake()
 {
     if (_instance != null)
     {
         return;
     }
     _instance = this;
 }
コード例 #6
0
ファイル: Demo.cs プロジェクト: c30gcrk/ios_photo
        /// <summary>
        /// 从相册_时刻/照片中获取图片成功回调
        /// </summary>
        /// <param name="imgDataStr"></param>
        void GetImgDataFromAlbum(string imgDataStr)
        {
            Debug.Log("Unity 调用相册 完成回调");

            Texture2D tex = IOSAlbumCamera.Base64StringToTexture2D(imgDataStr);

            img.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
            Debug.Log("tackor tex.w= " + tex.width + "; tex.h= " + tex.height + "; sprite= " + img.sprite);
        }
コード例 #7
0
ファイル: IOSAlbumCamera.cs プロジェクト: c30gcrk/ios_photo
 void Awake()
 {
     if (_instance != null)
     {
         DestroyImmediate(this);
         return;
     }
     _instance = this;
 }
コード例 #8
0
    void onclick_saveToAlbum()
    {
        string path = Application.persistentDataPath + "/lzhscreenshot.png";

        Debug.Log(path);
        byte[] bytes = (rawImage.texture as Texture2D).EncodeToPNG();
        System.IO.File.WriteAllBytes(path, bytes);

        IOSAlbumCamera.iosSaveImageToPhotosAlbum(path);
    }
コード例 #9
0
    void Awake()
    {
        if (_instance != null)
        {
            DestroyImmediate(this);
            return;
        }
        _instance = this;
//		GameObject go = new GameObject ("IOSAlbumCamera");
//		_instance = go.AddComponent<IOSAlbumCamera> ();
    }
コード例 #10
0
        private void XiangCe(GameObject obj)
        {
#if UNITY_ANDROID
            AndroidJavaClass  jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity");
            jo.Call("TakePhoto", 1, 200, 200, "personalcenter", "HeadImage");
#elif UNITY_IPHONE
            IOSAlbumCamera.iosOpenPhotoAlbums(true);
#endif
            // AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            // AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
            // jo.Call("TakePhoto", 1, 200, 200);
        }
コード例 #11
0
        private void PaiZhao(GameObject obj)
        {
            // AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            // AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
            // jo.Call("TakePhoto", 0, 200, 200);

#if UNITY_ANDROID
            AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            Console.Error.WriteLine("掉漆当前的具体的activity----" + jc);
            AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity");
            jo.Call("TakePhoto", 0, 200, 200, "personalcenter", "HeadImage");
#elif UNITY_IPHONE
            IOSAlbumCamera.iosOpenCamera(true);
#endif
        }
コード例 #12
0
        /// <summary>
        /// Adds the pick up compent.添加手机截图的组建
        /// </summary>
        /// <param name="go">Go.</param>
        private void addPickUpCompent(GameObject go)
        {
#if UNITY_ANDROID
            Console.WriteLine("当前是安卓平台啊");
            if (null == androidCallBack)
            {
                androidCallBack = go.AddComponent <AndroidPhoneCallBack>();
            }
            androidCallBack.img_selecthead = picHead;
#elif UNITY_IPHONE
            Console.WriteLine("当前是ios平台啊");
            if (null == iphoneCallBack)
            {
                iphoneCallBack = go.AddComponent <IOSAlbumCamera> ();
            }
            iphoneCallBack.img_selecthead = picHead;
#endif
        }
コード例 #13
0
ファイル: SaveImg.cs プロジェクト: soldiers1989/XLXQP
    IEnumerator CaptureScreenshot()
    {
        //只在每一帧渲染完成后才读取屏幕信息
        yield return(new WaitForEndOfFrame());

        //读取屏幕像素信息并存储为纹理数据
        screenShot.ReadPixels(new Rect(Screen.width * 0.14f, Screen.height * 0.37f, Screen.width * 0.69f, Screen.height * 0.48f), 0, 0);
        screenShot.Apply();// 这一句必须有,像素信息并没有保存在2D纹理贴图中

        //读取将这些纹理数据,成一个png图片文件
        byte[] bytes = screenShot.EncodeToPNG();

        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            string path = Application.persistentDataPath + "/QR" + Time.time.ToString() + ".png";
            Debug.Log(path);
            File.WriteAllBytes(path, bytes);
            IOSAlbumCamera.iosSaveImageToPhotosAlbum(path);
        }
        //安卓平台
        else if (Application.platform == RuntimePlatform.Android)
        {
            string destination = "/sdcard/DCIM";
            string fileName    = "erweima.png";
            //判断目录是否存在,不存在则会创建目录
            if (!Directory.Exists(destination))
            {
                Directory.CreateDirectory(destination);
                Debug.Log("创建目录成功");
                Debug.Log("destination");
            }
            string path = destination + "/" + fileName;
            //存图片
            System.IO.File.WriteAllBytes(path, bytes);
        }
        else
        {
            System.IO.File.WriteAllBytes(Application.persistentDataPath + "/1.png", bytes);
            Debug.Log(Application.persistentDataPath);
        }
    }
コード例 #14
0
ファイル: IOSPhoto.cs プロジェクト: qyadmin/RaisePigLarge
 public void OpenCamera()
 {
     IOSAlbumCamera.iosOpenCamera(true);
 }
コード例 #15
0
    private IEnumerator StartUp()
    {
        KernelManager kernelMgr = KernelManager.Instance();

        if (kernelMgr == null)
        {
            kernelMgr = new KernelManager();
        }
        HotFixUpdate hotFixUpdater = kernelMgr.AddKernel <HotFixUpdate>();

        if (!AppDefine.IsAppStartUped)
        {
            kernelMgr.AddKernel <GameManager>();
            kernelMgr.AddKernel <TimeManager>();
            kernelMgr.AddKernel <SMSManager>();
            kernelMgr.AddKernel <JPushManager>();
            kernelMgr.AddKernel <ShareSDKManager>();
            // QRCode 所需初始化
            IOSAlbumCamera.Init();
            WindowManager.InitWindowManager();

            if (isOpenHotFix)// 判断是否需要拷贝初始资源
            {
                HotFixUpdate.HotfixProgressChangedEvent += HotFixUpdate_HotfixProgressChangedEvent;
                yield return(StartCoroutine(HotFixUpdate.Instance().TryUpdateAssetFromStreamingAssets()));

                HotFixUpdate.HotfixProgressChangedEvent -= HotFixUpdate_HotfixProgressChangedEvent;
                if (m_FirstHandleProgressTips != null)
                {
                    m_FirstHandleProgressTips.gameObject.SetActive(false);
                }
            }
        }
        else
        {
            WindowManager.Instance.CloseAllWindows();
        }

        // 注册资源管理器
        AssetBundleManager assetBundleMgr = AssetBundleManager.Instance;

        while (!assetBundleMgr.IsReady)
        {
            yield return(1);
        }

        if (assetBundleMgr.LaunchFailed)
        {
            Application.Quit();
        }

        LoadingUI.Show();

        if (isOpenHotFix)
        {
            hotFixUpdater.TryStartUpdateRemoteAssetsToLocal();
            while (hotFixUpdater.IsWorking)
            {
                yield return(1);
            }
            // 更新管理器完成了
            if (hotFixUpdater.UpdaterState == HotFixUpdaterState.Done)
            {
                if (!hotFixUpdater.IsValidatedAssets)
                {
                    Debug.LogError("HotfixUpdate error, the assets was not validated!");
                    Application.Quit();
                    yield break;
                }
                // 有更新资源,需要重新加载资源管理器
                if (hotFixUpdater.IsLoadedNewAsset)
                {
                    //WindowManager.Instance.CloseWindow(LoadingUI.UIAssetName, false);
                    LoadingUI.Hide();
                    HotFixUpdate_HotfixProgressChangedEvent(null, new HotfixProgressChangedEventArgs(50, "载入新的游戏资源..."));
                    AssetBundleManager.Instance.ReLaunch();
                    while (!AssetBundleManager.Instance.IsReady)
                    {
                        yield return(1);
                    }
                    if (AssetBundleManager.Instance.LaunchFailed)
                    {
                        Application.Quit();
                    }
                    LoadingUI.Show();
                }
            }
        }

        // 初始化网络管理器
        kernelMgr.AddKernel <Net.ConnectManager>();
        Net.ConnectManager.Instance().CloseAllNetworkClient();
        // 初始化对象池管理器
        LuaAsynFuncMgr.Instance.Init();

        // 初始化Lua管理器
        if (!AppDefine.IsAppStartUped)
        {
            LuaManager.Instance.Launch();
        }
        else
        {
            LuaManager.Instance.ReLaunch();
        }

        while (!LuaManager.Instance.IsReady)
        {
            yield return(1);
        }
        if (LuaManager.Instance.LaunchFailed)
        {
            Application.Quit();
        }
        yield return(1);

        LuaManager.Instance.StartUp();

        kernelMgr.DeleteKernel <HotFixUpdate>();
        GameObject.Destroy(this);

        GameObject splashObj = GameObject.Find("SplashUI");

        if (splashObj != null)
        {
            GameObject.Destroy(splashObj);
        }

        AppDefine.IsAppStartUped = true;
    }
コード例 #16
0
ファイル: Demo.cs プロジェクト: c30gcrk/ios_photo
 /// <summary>
 /// 从摄像头获取(图片不会保存到相册中)
 /// </summary>
 void OpenCamera()
 {
     Debug.Log("Unity 打开相机 --> ");
     IOSAlbumCamera.iosOpenCamera(false);
 }
コード例 #17
0
ファイル: Demo.cs プロジェクト: c30gcrk/ios_photo
 /// <summary>
 /// 从相册_时刻获取图片
 /// </summary>
 void GetPictureFromMoment()
 {
     Debug.Log("Unity 打开相册_时刻 --> ");
     IOSAlbumCamera.iosOpenPhotoAlbums(false);
 }
コード例 #18
0
ファイル: Demo.cs プロジェクト: c30gcrk/ios_photo
 /// <summary>
 /// 从相册_照片获取图片
 /// </summary>
 void GetPictureFromPhone()
 {
     Debug.Log("Unity 打开相册_照片 --> ");
     IOSAlbumCamera.iosOpenPhotoLibrary(false);
 }
コード例 #19
0
 void onclick_photos()
 {
     IOSAlbumCamera.iosOpenPhotoLibrary(true);
 }
コード例 #20
0
ファイル: IOSPhoto.cs プロジェクト: qyadmin/RaisePigLarge
 public void OpenPhoto()
 {
     IOSAlbumCamera.iosOpenPhotoLibrary(true);
 }
コード例 #21
0
 void onclick_album()
 {
     IOSAlbumCamera.iosOpenPhotoAlbums(true);
 }
コード例 #22
0
 void onclick_camera()
 {
     IOSAlbumCamera.iosOpenCamera(true);
 }