62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using Coolape;
|
|||
|
|
|
|||
|
|
public static class MyCamera
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
public static NativeCamera.Permission getImage(object callback, int maxSize = -1)
|
|||
|
|
{
|
|||
|
|
NativeCamera.Permission pm;
|
|||
|
|
pm = NativeCamera.CheckPermission();
|
|||
|
|
if (pm == NativeCamera.Permission.Granted)
|
|||
|
|
{
|
|||
|
|
NativeCamera.TakePicture((path) =>
|
|||
|
|
{
|
|||
|
|
Utl.doCallback(callback, path);
|
|||
|
|
}, maxSize, true, NativeCamera.PreferredCamera.Default);
|
|||
|
|
}
|
|||
|
|
return pm;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static NativeCamera.Permission getImageFacing(object callback, int maxSize = -1)
|
|||
|
|
{
|
|||
|
|
NativeCamera.Permission pm;
|
|||
|
|
pm = NativeCamera.CheckPermission();
|
|||
|
|
if (pm == NativeCamera.Permission.Granted)
|
|||
|
|
{
|
|||
|
|
NativeCamera.TakePicture((path) =>
|
|||
|
|
{
|
|||
|
|
Utl.doCallback(callback, path);
|
|||
|
|
}, maxSize, true, NativeCamera.PreferredCamera.Front);
|
|||
|
|
}
|
|||
|
|
return pm;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static NativeCamera.Permission getVideo(object callback)
|
|||
|
|
{
|
|||
|
|
NativeCamera.Permission pm;
|
|||
|
|
pm = NativeCamera.CheckPermission();
|
|||
|
|
if (pm == NativeCamera.Permission.Granted)
|
|||
|
|
{
|
|||
|
|
NativeCamera.RecordVideo((path) =>
|
|||
|
|
{
|
|||
|
|
Utl.doCallback(callback, path);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
return pm;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static bool openSetting()
|
|||
|
|
{
|
|||
|
|
if (NativeCamera.CanOpenSettings())
|
|||
|
|
{
|
|||
|
|
NativeCamera.OpenSettings();
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|