Commit 708d3dee authored by BlackAngle233's avatar BlackAngle233
Browse files

update final design

parent 1444629e
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using System;
using UnityEngine;
namespace easyar
{
/// <summary>
/// <para xml:lang="en"><see cref="MonoBehaviour"/> which controls <see cref="CameraDevice"/> in the scene, providing a few extensions in the Unity environment. Use <see cref="Device"/> directly when necessary.</para>
/// <para xml:lang="zh">在场景中控制<see cref="CameraDevice"/>的<see cref="MonoBehaviour"/>,在Unity环境下提供功能扩展。如有需要可以直接使用<see cref="Device"/>。</para>
/// </summary>
public class VideoCameraDevice : CameraSource
{
/// <summary>
/// <para xml:lang="en">EasyAR Sense API. Accessible between <see cref="DeviceCreated"/> and <see cref="DeviceClosed"/> event if available.</para>
/// <para xml:lang="zh">EasyAR Sense API,如果功能可以使用,可以在<see cref="DeviceCreated"/>和<see cref="DeviceClosed"/>事件之间访问。</para>
/// </summary>
public CameraDevice Device { get; private set; }
/// <summary>
/// <para xml:lang="en">Focus mode used only when create <see cref="Device"/>.</para>
/// <para xml:lang="zh">创建<see cref="Device"/>时使用的聚焦模式,只在创建时使用。</para>
/// </summary>
public CameraDeviceFocusMode FocusMode = CameraDeviceFocusMode.Continousauto;
/// <summary>
/// <para xml:lang="en">Camera preview size used only when create <see cref="Device"/>.</para>
/// <para xml:lang="zh">创建<see cref="Device"/>时使用的图像大小,只在创建时使用。</para>
/// </summary>
public Vector2 CameraSize = new Vector2(1280, 960);
/// <summary>
/// <para xml:lang="en">Camera open method used only when create <see cref="Device"/>.</para>
/// <para xml:lang="zh">创建<see cref="Device"/>时使用的方法,只在创建时使用。</para>
/// </summary>
public CameraDeviceOpenMethod CameraOpenMethod = CameraDeviceOpenMethod.DeviceType;
/// <summary>
/// <para xml:lang="en">Camera type used only when create <see cref="Device"/>, used when <see cref="CameraOpenMethod"/> == <see cref="CameraDeviceOpenMethod.DeviceType"/>.</para>
/// <para xml:lang="zh">创建<see cref="Device"/>时使用的Camera类型,只在创建时<see cref="CameraOpenMethod"/> == <see cref="CameraDeviceOpenMethod.DeviceType"/>的时候使用。</para>
/// </summary>
[HideInInspector, SerializeField]
public CameraDeviceType CameraType = CameraDeviceType.Back;
/// <summary>
/// <para xml:lang="en">Camera index used only when create <see cref="Device"/>, used when <see cref="CameraOpenMethod"/> == <see cref="CameraDeviceOpenMethod.DeviceIndex"/>.</para>
/// <para xml:lang="zh">创建<see cref="Device"/>时使用的设备索引,只在创建时<see cref="CameraOpenMethod"/> == <see cref="CameraDeviceOpenMethod.DeviceIndex"/>的时候使用。</para>
/// </summary>
[HideInInspector, SerializeField]
public int CameraIndex = 0;
[HideInInspector, SerializeField]
private CameraDevicePreference cameraPreference = CameraDevicePreference.PreferObjectSensing;
private CameraParameters parameters = null;
private bool willOpen;
/// <summary>
/// <para xml:lang="en">Event when <see cref="Device"/> created.</para>
/// <para xml:lang="zh"><see cref="Device"/> 创建的事件。</para>
/// </summary>
public event Action DeviceCreated;
/// <summary>
/// <para xml:lang="en">Event when <see cref="Device"/> opened.</para>
/// <para xml:lang="zh"><see cref="Device"/> 打开的事件。</para>
/// </summary>
public event Action DeviceOpened;
/// <summary>
/// <para xml:lang="en">Event when <see cref="Device"/> closed.</para>
/// <para xml:lang="zh"><see cref="Device"/> 关闭的事件。</para>
/// </summary>
public event Action DeviceClosed;
/// <summary>
/// <para xml:lang="en">Open method of <see cref="CameraDevice"/>.</para>
/// <para xml:lang="zh"><see cref="CameraDevice"/>开启方式。</para>
/// </summary>
public enum CameraDeviceOpenMethod
{
/// <summary>
/// <para xml:lang="en">Open <see cref="CameraDevice"/> type.</para>
/// <para xml:lang="zh">根据<see cref="CameraDevice"/>的类型打开<see cref="CameraDevice"/>。</para>
/// </summary>
DeviceType,
/// <summary>
/// <para xml:lang="en">Open <see cref="CameraDevice"/> index.</para>
/// <para xml:lang="zh">根据<see cref="CameraDevice"/>的索引打开<see cref="CameraDevice"/>。</para>
/// </summary>
DeviceIndex,
}
public override int BufferCapacity
{
get
{
if (Device != null)
{
return Device.bufferCapacity();
}
return bufferCapacity;
}
set
{
bufferCapacity = value;
if (Device != null)
{
Device.setBufferCapacity(value);
}
}
}
public override bool HasSpatialInformation
{
get { return false; }
}
/// <summary>
/// <para xml:lang="en">Camera preference used only when create <see cref="Device"/>. It will switch focus mode to the preferred value, change the focus after this value changed if it not the desired case.</para>
/// <para xml:lang="zh">创建<see cref="Device"/>时使用的Camera偏好设置,只在创建时使用。它会同时控制对焦模式到推荐使用值,如果需要使用特定对焦模式,需要在修改这个值之后重新设置对焦模式。</para>
/// </summary>
public CameraDevicePreference CameraPreference
{
get { return cameraPreference; }
// Switch to preferred FocusMode when switch CameraPreference.
// You can set other FocusMode after this, but the tracking results may differ.
set
{
cameraPreference = value;
FocusMode = CameraDeviceSelector.getFocusMode(cameraPreference);
}
}
/// <summary>
/// <para xml:lang="en">Camera parameters used only when create <see cref="Device"/>. It is for advanced usage and will overwrite other values like <see cref="CameraSize"/>.</para>
/// <para xml:lang="zh">创建<see cref="Device"/>时使用的相机参数,只在创建时使用。这个参数是高级设置,会覆盖<see cref="CameraSize"/>等其它值。</para>
/// </summary>
public CameraParameters Parameters
{
get
{
if (Device != null)
{
return Device.cameraParameters();
}
return parameters;
}
set
{
parameters = value;
}
}
/// <summary>
/// MonoBehaviour OnEnable
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
if (Device != null)
{
Device.start();
}
}
/// <summary>
/// MonoBehaviour Start
/// </summary>
protected override void Start()
{
if (!CameraDevice.isAvailable())
{
throw new UIPopupException(typeof(CameraDevice) + " not available");
}
base.Start();
}
/// <summary>
/// MonoBehaviour OnDisable
/// </summary>
protected override void OnDisable()
{
base.OnDisable();
if (Device != null)
{
Device.stop();
}
}
public override void Open()
{
willOpen = true;
CameraDevice.requestPermissions(EasyARController.Scheduler, (Action<PermissionStatus, string>)((status, msg) =>
{
if (!willOpen)
{
return;
}
if (status != PermissionStatus.Granted)
{
throw new UIPopupException("Camera permission not granted");
}
Close();
Device = CameraDeviceSelector.createCameraDevice(CameraPreference);
if (DeviceCreated != null)
{
DeviceCreated();
}
bool openResult = false;
switch (CameraOpenMethod)
{
case CameraDeviceOpenMethod.DeviceType:
openResult = Device.openWithPreferredType(CameraType);
break;
case CameraDeviceOpenMethod.DeviceIndex:
openResult = Device.openWithIndex(CameraIndex);
break;
default:
break;
}
if (!openResult)
{
Debug.LogError("Camera open failed");
Device.Dispose();
Device = null;
return;
}
Device.setFocusMode(FocusMode);
Device.setSize(new Vec2I((int)CameraSize.x, (int)CameraSize.y));
if (parameters != null)
{
Device.setCameraParameters(parameters);
}
if (bufferCapacity != 0)
{
Device.setBufferCapacity(bufferCapacity);
}
if (sink != null)
Device.inputFrameSource().connect(sink);
if (DeviceOpened != null)
{
DeviceOpened();
}
if (enabled)
{
OnEnable();
}
}));
}
public override void Close()
{
willOpen = false;
if (Device != null)
{
OnDisable();
Device.close();
Device.Dispose();
if (DeviceClosed != null)
{
DeviceClosed();
}
Device = null;
}
}
public override void Connect(InputFrameSink val)
{
base.Connect(val);
if (Device != null)
{
Device.inputFrameSource().connect(val);
}
}
}
}
fileFormatVersion: 2
guid: dca8017ddc105e5488bf7ba9b4a177cd
timeCreated: 1562759280
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using System;
using UnityEngine;
using UnityEngine.Rendering;
namespace easyar
{
/// <summary>
/// <para xml:lang="en"><see cref="MonoBehaviour"/> which controls <see cref="Recorder"/> in the scene, providing a few extensions in the Unity environment. There is no need to use <see cref="Recorder"/> directly.</para>
/// <para xml:lang="en">You have full control of what is recorded. The recorder do not record the screen or the camera output silently, the video data being recorded should be passed in continuously using <see cref="RecordFrame"/></para>
/// <para xml:lang="zh">在场景中控制<see cref="Recorder"/>的<see cref="MonoBehaviour"/>,在Unity环境下提供功能扩展。不需要直接使用<see cref="Recorder"/>。</para>
/// <para xml:lang="zh">用户对视频录制的内容有完全控制,录屏功能不会默默地录制屏幕或是camera输出,录制的视频数据需要通过<see cref="RecordFrame"/>不断传入。</para>
/// </summary>
public class VideoRecorder : MonoBehaviour
{
/// <summary>
/// <para xml:lang="en">Record profile used only when create.</para>
/// <para xml:lang="zh">创建时使用的录屏配置,只在创建时使用。</para>
/// </summary>
public RecordProfile Profile = RecordProfile.Quality_Default;
/// <summary>
/// <para xml:lang="en">Record video orientation used only when create.</para>
/// <para xml:lang="zh">创建时使用的录屏视频朝向,只在创建时使用。</para>
/// </summary>
public VideoOrientation Orientation = VideoOrientation.ScreenAdaptive;
/// <summary>
/// <para xml:lang="en">Record zoom mode used only when create.</para>
/// <para xml:lang="zh">创建时使用的录屏缩放模式,只在创建时使用。</para>
/// </summary>
public RecordZoomMode RecordZoomMode;
/// <summary>
/// <para xml:lang="en">Record output file path type used only when create.</para>
/// <para xml:lang="zh">创建时使用的录屏文件输出路径类型,只在创建时使用。</para>
/// </summary>
public WritablePathType FilePathType;
/// <summary>
/// <para xml:lang="en">Record output file path used only when create.</para>
/// <para xml:lang="zh">创建时使用的录屏文件输出路径,只在创建时使用。</para>
/// </summary>
public string FilePath = string.Empty;
private Recorder recorder;
/// <summary>
/// <para xml:lang="en">Event when record status changes.</para>
/// <para xml:lang="zh">录屏状态变化的事件。</para>
/// </summary>
public event Action<RecordStatus, string> StatusUpdate;
/// <summary>
/// <para xml:lang="en">The recorder can be used. Recorder cannot work if permission not granted.</para>
/// <para xml:lang="zh">录屏可以使用。如果权限未被允许录屏将无法使用。</para>
/// </summary>
public bool IsReady { get; private set; }
/// <summary>
/// <para xml:lang="en">Record video orientation.</para>
/// <para xml:lang="zh">录屏视频朝向。</para>
/// </summary>
public enum VideoOrientation
{
/// <summary>
/// <para xml:lang="en">Video recorded is landscape.</para>
/// <para xml:lang="zh">录制的视频是横向。</para>
/// </summary>
Landscape = RecordVideoOrientation.Landscape,
/// <summary>
/// <para xml:lang="en">Video recorded is portrait.</para>
/// <para xml:lang="zh">录制的视频是竖向。</para>
/// </summary>
Portrait = RecordVideoOrientation.Portrait,
/// <summary>
/// <para xml:lang="en">Video orientation fit screen aspect ratio automatically.</para>
/// <para xml:lang="zh">录制的视频朝向根据屏幕比例自动调整。</para>
/// </summary>
ScreenAdaptive,
}
/// <summary>
/// MonoBehaviour Start
/// </summary>
protected virtual void Start()
{
if (!EasyARController.Initialized)
{
return;
}
if (Application.platform != RuntimePlatform.Android && Application.platform != RuntimePlatform.IPhonePlayer)
{
throw new UIPopupException(typeof(Recorder) + " not available under " + Application.platform);
}
if (SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLES2 && SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLES3)
{
throw new UIPopupException(typeof(Recorder) + " not available under " + SystemInfo.graphicsDeviceType);
}
if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.OpenGLES3 && Application.platform == RuntimePlatform.IPhonePlayer)
{
throw new UIPopupException(typeof(Recorder) + " not available under " + Application.platform + " with " + SystemInfo.graphicsDeviceType);
}
if (SystemInfo.graphicsMultiThreaded)
{
throw new UIPopupException(typeof(Recorder) + " not available when using multi-thread rendering");
}
if (!Recorder.isAvailable())
{
throw new UIPopupException(typeof(Recorder) + " not available");
}
Recorder.requestPermissions(EasyARController.Scheduler, (Action<PermissionStatus, string>)((status, msg) =>
{
if (status != PermissionStatus.Granted)
{
throw new UIPopupException("Recorder permission not granted");
}
IsReady = true;
}));
}
/// <summary>
/// MonoBehaviour OnDestroy
/// </summary>
protected virtual void OnDestroy()
{
StopRecording();
}
/// <summary>
/// <para xml:lang="en">Start recording using configuration set in the component. The video data being recorded should be passed in continuously using <see cref="RecordFrame"/>。</para>
/// <para xml:lang="zh">开始录屏,录屏中使用的配置使用组件内配置。录制的视频数据需要通过<see cref="RecordFrame"/>不断传入。</para>
/// </summary>
public bool StartRecording()
{
using (var configuration = new RecorderConfiguration())
{
var path = FilePath;
if (FilePathType == WritablePathType.PersistentDataPath)
{
path = Application.persistentDataPath + "/" + path;
}
configuration.setOutputFile(path);
configuration.setProfile(Profile);
configuration.setZoomMode(RecordZoomMode);
RecordVideoOrientation orientation;
switch (Orientation)
{
case VideoOrientation.Portrait:
orientation = RecordVideoOrientation.Portrait;
break;
case VideoOrientation.Landscape:
orientation = RecordVideoOrientation.Landscape;
break;
default:
orientation = Screen.width > Screen.height ? RecordVideoOrientation.Landscape : RecordVideoOrientation.Portrait;
break;
}
configuration.setVideoOrientation(orientation);
return StartRecording(configuration);
}
}
/// <summary>
/// <para xml:lang="en">Start recording using <paramref name="configuration"/>. The configuration set in the component will be ignored. The video data being recorded should be passed in continuously using <see cref="RecordFrame"/></para>
/// <para xml:lang="zh">开始录屏,录屏中使用的配置使用<paramref name="configuration"/>。组件内配置将被忽略。录制的视频数据需要通过<see cref="RecordFrame"/>不断传入。</para>
/// </summary>
public bool StartRecording(RecorderConfiguration configuration)
{
if (!IsReady || recorder != null)
{
return false;
}
recorder = Recorder.create(configuration, EasyARController.Scheduler, (Action<RecordStatus, string>)((status, message) =>
{
if (StatusUpdate != null)
{
StatusUpdate(status, message);
}
}));
recorder.start();
return true;
}
/// <summary>
/// <para xml:lang="en">Stop recording.</para>
/// <para xml:lang="zh">停止录屏。</para>
/// </summary>
public bool StopRecording()
{
if (recorder == null)
{
return false;
}
bool status = recorder.stop();
recorder.Dispose();
recorder = null;
return status;
}
/// <summary>
/// <para xml:lang="en">Record a frame using <paramref name="texture"/>.</para>
/// <para xml:lang="zh">使用<paramref name="texture"/>录制一帧数据。</para>
/// </summary>
public bool RecordFrame(RenderTexture texture)
{
if (recorder == null)
{
return false;
}
using (var textureId = TextureId.fromInt(texture.GetNativeTexturePtr().ToInt32()))
{
recorder.updateFrame(textureId, texture.width, texture.height);
}
return true;
}
}
}
fileFormatVersion: 2
guid: 2e535ae0ffb10584ea05e06d4102482c
timeCreated: 1567050123
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using System;
using UnityEngine;
namespace easyar
{
/// <summary>
/// <para xml:lang="en"><see cref="MonoBehaviour"/> which controls EasyAR Sense initialization and some global settings.</para>
/// <para xml:lang="zh">在场景中控制EasyAR Sense初始化以及一些全局设置的<see cref="MonoBehaviour"/>。</para>
/// </summary>
public class EasyARController : MonoBehaviour
{
/// <summary>
/// <para xml:lang="en">If popup message will be displayed. All popup message from EasyAR Sense Unity Plugin is controlled by this flag.</para>
/// <para xml:lang="zh">是否显示弹出消息。所有EasyAR Sense Unity Plugin的弹出消息都又这个flag控制。</para>
/// </summary>
public bool ShowPopupMessage = true;
private static EasyARSettings settings;
/// <summary>
/// <para xml:lang="en">Global <see cref="EasyARController"/>.</para>
/// <para xml:lang="zh">全局<see cref="EasyARController"/>。</para>
/// </summary>
public static EasyARController Instance { get; private set; }
/// <summary>
/// <para xml:lang="en">EasyAR Sense initialize result, false if license key validation fails.</para>
/// <para xml:lang="zh">EasyAR Sense初始化结果。如果license key验证失败会是false。</para>
/// </summary>
public static bool Initialized { get; private set; }
/// <summary>
/// <para xml:lang="en">If ARCore load fails.</para>
/// <para xml:lang="zh">ARCore加载是否失败。</para>
/// </summary>
public static bool ARCoreLoadFailed { get; private set; }
/// <summary>
/// <para xml:lang="en">Global Scheduler. Accessible after scene loaded.</para>
/// <para xml:lang="zh">全局回调调度器。可以在场景加载之后访问。</para>
/// </summary>
public static DelayedCallbackScheduler Scheduler { get; private set; }
/// <summary>
/// <para xml:lang="en">Global <see cref="EasyARSettings"/>.</para>
/// <para xml:lang="zh">全局<see cref="EasyARSettings"/>。</para>
/// </summary>
public static EasyARSettings Settings
{
get
{
if (!settings)
{
settings = Resources.Load<EasyARSettings>(settingsPath);
}
return settings;
}
}
private static string settingsPath { get { return "EasyAR/Settings"; } }
/// <summary>
/// <para xml:lang="en">Thread worker. Accessible after Awake.</para>
/// <para xml:lang="zh">线程工作器。可以在Awake之后访问。</para>
/// </summary>
public ThreadWorker Worker { get; private set; }
/// <summary>
/// <para xml:lang="en">Internal use only. Display information.</para>
/// <para xml:lang="zh">内部使用。显示设备信息。</para>
/// </summary>
internal Display Display { get; private set; }
/// <summary>
/// <para xml:lang="en">EasyAR Sense initialization, called before Unity load scenes.</para>
/// <para xml:lang="zh">初始化EasyAR Sense,在Unity场景加载前调用。</para>
/// </summary>
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
public static void GlobalInitialization()
{
Debug.Log("EasyAR Sense Unity Plugin Version " + EasyARVersion.FullVersion);
#if UNITY_ANDROID && !UNITY_EDITOR
if (Settings.ARCoreSupport)
{
try
{
using (var systemClass = new AndroidJavaClass("java.lang.System"))
{
systemClass.CallStatic("loadLibrary", "arcore_sdk_c");
}
}
catch (AndroidJavaException)
{
ARCoreLoadFailed = true;
}
}
#endif
Initialized = false;
Scheduler = new DelayedCallbackScheduler();
#if UNITY_EDITOR
Log.setLogFuncWithScheduler(Scheduler, (LogLevel, msg) =>
{
switch (LogLevel)
{
case LogLevel.Error:
Debug.LogError(msg);
break;
case LogLevel.Warning:
Debug.LogWarning(msg);
break;
case LogLevel.Info:
Debug.Log(msg);
break;
default:
break;
}
});
#endif
var key = Settings.LicenseKey;
System.AppDomain.CurrentDomain.DomainUnload += (sender, e) =>
{
#if UNITY_EDITOR
Log.resetLogFunc();
#endif
if (Scheduler != null)
{
Scheduler.Dispose();
}
settings = null;
};
#if UNITY_ANDROID && !UNITY_EDITOR
using (var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
using (var currentActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"))
using (var easyarEngineClass = new AndroidJavaClass("cn.easyar.Engine"))
{
var activityclassloader = currentActivity.Call<AndroidJavaObject>("getClass").Call<AndroidJavaObject>("getClassLoader");
if (activityclassloader == null)
{
Debug.Log("ActivityClassLoader is null");
}
easyarEngineClass.CallStatic("loadLibraries");
if (!easyarEngineClass.CallStatic<bool>("setupActivity", currentActivity))
{
Debug.LogError("EasyAR Sense Initialize Fail");
Initialized = false;
return;
}
}
#endif
if (!Engine.initialize(key.Trim()))
{
Debug.LogError("EasyAR Sense Initialize Fail");
Initialized = false;
return;
}
else
{
Initialized = true;
}
System.AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
Debug.Log("UnhandledException: " + e.ExceptionObject.ToString());
};
}
/// <summary>
/// MonoBehaviour Awake
/// </summary>
private void Awake()
{
Instance = this;
Display = new Display();
Worker = new ThreadWorker();
if (!Initialized)
{
ShowErrorMessage();
}
}
/// <summary>
/// MonoBehaviour Update
/// </summary>
private void Update()
{
if (!Initialized)
{
return;
}
var error = Engine.errorMessage();
if (!string.IsNullOrEmpty(error))
{
ShowErrorMessage();
Initialized = false;
}
if (Scheduler != null)
{
while (Scheduler.runOne())
{
}
}
}
/// <summary>
/// MonoBehaviour OnApplicationPause
/// </summary>
private void OnApplicationPause(bool pause)
{
if (pause)
{
Engine.onPause();
}
else
{
Engine.onResume();
}
}
/// <summary>
/// MonoBehaviour OnDestroy
/// </summary>
private void OnDestroy()
{
Worker.Dispose();
Display.Dispose();
}
private void ShowErrorMessage()
{
if (Application.isEditor || string.IsNullOrEmpty(Settings.LicenseKey))
{
GUIPopup.EnqueueMessage(Engine.errorMessage() + Environment.NewLine +
"Fill a valid Key in EasyAR Settings Asset" + Environment.NewLine +
"Menu entry: <EasyAR/Change License Key>" + Environment.NewLine +
"Asset Path: " + settingsPath + Environment.NewLine +
"Get from EasyAR Develop Center (www.easyar.com) -> SDK Authorization", 10000);
}
else
{
GUIPopup.EnqueueMessage(Engine.errorMessage() + Environment.NewLine +
"Get from EasyAR Develop Center (www.easyar.com) -> SDK Authorization", 10000);
}
}
}
}
fileFormatVersion: 2
guid: 845309652a1ed494d89639fa567f4a29
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using System;
using UnityEngine;
namespace easyar
{
/// <summary>
/// <para xml:lang="en">EasyAR Sense settings.</para>
/// <para xml:lang="zh">EasyAR Sense的配置信息。</para>
/// </summary>
[CreateAssetMenu(menuName = "EasyAR/Settings")]
public class EasyARSettings : ScriptableObject
{
/// <summary>
/// <para xml:lang="en">EasyAR Sense License Key。Used for validation of EasyAR Sense functions. Please visit https://www.easyar.com for more details.</para>
/// <para xml:lang="zh">EasyAR Sense License Key。用于验证EasyAR Sense内部各种功能是否可用。详见 https://www.easyar.cn 。</para>
/// </summary>
[HideInInspector, SerializeField]
[TextArea(1, 10)]
public string LicenseKey;
/// <summary>
/// <para xml:lang="en"><see cref="Gizmos"/> configuration for <see cref="ImageTarget"/> and <see cref="ObjectTarget"/>.</para>
/// <para xml:lang="zh"><see cref="ImageTarget"/> 和 <see cref="ObjectTarget"/>的<see cref="Gizmos"/>配置。</para>
/// </summary>
public TargetGizmoConfig GizmoConfig = new TargetGizmoConfig();
/// <summary>
/// <para xml:lang="en">Global spatial map service config.</para>
/// <para xml:lang="zh">全局稀疏地图服务器配置。</para>
/// </summary>
public SparseSpatialMapWorkerFrameFilter.SpatialMapServiceConfig GlobalSpatialMapServiceConfig = new SparseSpatialMapWorkerFrameFilter.SpatialMapServiceConfig();
/// <summary>
/// <para xml:lang="en">Global cloud recognizer service config.</para>
/// <para xml:lang="zh">全局云识别服务器配置。</para>
/// </summary>
public CloudRecognizerFrameFilter.CloudRecognizerServiceConfig GlobalCloudRecognizerServiceConfig = new CloudRecognizerFrameFilter.CloudRecognizerServiceConfig();
/// <summary>
/// <para xml:lang="en">ARCore support (will load arcore lib).</para>
/// <para xml:lang="zh">添加ARCore支持(将会加载ARCore库)。</para>
/// </summary>
public bool ARCoreSupport = true;
/// <summary>
/// <para xml:lang="en"><see cref="Gizmos"/> configuration for target.</para>
/// <para xml:lang="zh">Target的<see cref="Gizmos"/>配置。</para>
/// </summary>
[Serializable]
public class TargetGizmoConfig
{
/// <summary>
/// <para xml:lang="en"><see cref="Gizmos"/> configuration for <see cref="easyar.ImageTarget"/>.</para>
/// <para xml:lang="zh"><see cref="easyar.ImageTarget"/>的<see cref="Gizmos"/>配置。</para>
/// </summary>
public ImageTargetConfig ImageTarget = new ImageTargetConfig();
/// <summary>
/// <para xml:lang="en"><see cref="Gizmos"/> configuration for <see cref="easyar.ObjectTarget"/>.</para>
/// <para xml:lang="zh"><see cref="easyar.ObjectTarget"/>的<see cref="Gizmos"/>配置。</para>
/// </summary>
public ObjectTargetConfig ObjectTarget = new ObjectTargetConfig();
/// <summary>
/// <para xml:lang="en"><see cref="Gizmos"/> configuration for <see cref="easyar.ImageTarget"/>.</para>
/// <para xml:lang="zh"><see cref="easyar.ImageTarget"/>的<see cref="Gizmos"/>配置。</para>
/// </summary>
[Serializable]
public class ImageTargetConfig
{
/// <summary>
/// <para xml:lang="en">Enable <see cref="Gizmos"/> of target which <see cref="ImageTargetController.SourceType"/> equals to <see cref="ImageTargetController.DataSource.ImageFile"/>. Enable this option will load image file and display gizmo in Unity Editor, the startup performance of the Editor will be affected if there are too much target of this kind in the scene, but the Unity runtime will not be affected when running on devices.</para>
/// <para xml:lang="zh">开启<see cref="ImageTargetController.SourceType"/>类型为<see cref="ImageTargetController.DataSource.ImageFile"/>的target的<see cref="Gizmos"/>。打开这个将会在Unity Editor中加载图像文件并显示对应gizmo,如果场景中该类target过多,可能会影响编辑器中的启动性能。在设备上运行时,Unity运行时的性能不会受到影响。</para>
/// </summary>
public bool EnableImageFile = true;
/// <summary>
/// <para xml:lang="en">Enable <see cref="Gizmos"/> of target which <see cref="ImageTargetController.SourceType"/> equals to <see cref="ImageTargetController.DataSource.TargetDataFile"/>. Enable this option will target data file and display gizmo in Unity Editor, the startup performance of the Editor will be affected if there are too much target of this kind in the scene, but the Unity runtime will not be affected when running on devices.</para>
/// <para xml:lang="zh">开启<see cref="ImageTargetController.SourceType"/>类型为<see cref="ImageTargetController.DataSource.TargetDataFile"/>的target的<see cref="Gizmos"/>。打开这个将会在Unity Editor中加载target数据文件并显示显示对应gizmo,如果场景中该类target过多,可能会影响编辑器中的启动性能。在设备上运行时,Unity运行时的性能不会受到影响。</para>
/// </summary>
public bool EnableTargetDataFile = true;
/// <summary>
/// <para xml:lang="en">Enable <see cref="Gizmos"/> of target which <see cref="ImageTargetController.SourceType"/> equals to <see cref="ImageTargetController.DataSource.Target"/>. Enable this option will display gizmo in Unity Editor, the startup performance of the Editor will be affected if there are too much target of this kind in the scene, but the Unity runtime will not be affected when running on devices.</para>
/// <para xml:lang="zh">开启<see cref="ImageTargetController.SourceType"/>类型为<see cref="ImageTargetController.DataSource.Target"/>的target的<see cref="Gizmos"/>。打开这个将会在Unity Editor中显示对应gizmo,如果场景中该类target过多,可能会影响编辑器中的启动性能。在设备上运行时,Unity运行时的性能不会受到影响。</para>
/// </summary>
public bool EnableTarget = true;
}
/// <summary>
/// <para xml:lang="en"><see cref="Gizmos"/> configuration for <see cref="easyar.ObjectTarget"/>.</para>
/// <para xml:lang="zh"><see cref="easyar.ObjectTarget"/>的<see cref="Gizmos"/>配置。</para>
/// </summary>
[Serializable]
public class ObjectTargetConfig
{
/// <summary>
/// <para xml:lang="en">Enable <see cref="Gizmos"/>.</para>
/// <para xml:lang="zh">开启<see cref="Gizmos"/>。</para>
/// </summary>
public bool Enable = true;
}
}
}
}
fileFormatVersion: 2
guid: 963aaa1ae868b0140b6456db09120440
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using System;
namespace easyar
{
public sealed class EasyARVersion
{
public const String FullVersion = "4.2.0.1102-0415d235a";
}
}
fileFormatVersion: 2
guid: b621e15ca7e71c940886838dedaac689
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 6929289032cfbe241aa829b4035fda77
folderAsset: yes
timeCreated: 1571997682
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using UnityEditor;
using UnityEngine;
namespace easyar
{
[CustomEditor(typeof(EasyARSettings), true)]
public class EasyARSettingsEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
EditorGUILayout.PropertyField(serializedObject.FindProperty("LicenseKey"), new GUIContent("EasyAR SDK License Key"), true);
serializedObject.ApplyModifiedProperties();
}
}
}
fileFormatVersion: 2
guid: 70f552d7b725cb840a75a3e5295f88dd
timeCreated: 1574753117
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using UnityEditor;
using UnityEngine;
namespace easyar
{
public class LicenseKeyWindow : EditorWindow
{
[MenuItem("EasyAR/Change License Key")]
private static void OpenTheWindow()
{
Selection.SetActiveObjectWithContext(EasyARController.Settings, null);
}
}
public class SpatialMapServiceConfigWindow : EditorWindow
{
[MenuItem("EasyAR/Change Global Spatial Map Service Config")]
private static void OpenTheWindow()
{
Selection.SetActiveObjectWithContext(EasyARController.Settings, null);
}
}
public class CloudRecognizerServiceConfigWindow : EditorWindow
{
[MenuItem("EasyAR/Change Global Cloud Recognizer Service Config")]
private static void OpenTheWindow()
{
Selection.SetActiveObjectWithContext(EasyARController.Settings, null);
}
}
public class GizmoConfigWindow : EditorWindow
{
[MenuItem("EasyAR/Change Gizmo Config")]
private static void OpenTheWindow()
{
Selection.SetActiveObjectWithContext(EasyARController.Settings, null);
}
}
}
fileFormatVersion: 2
guid: a555b7684ac63e9499706c4cf58e5c90
timeCreated: 1575706162
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d9c864d11a7881147a2bcbdfdf153a3b
folderAsset: yes
timeCreated: 1594183908
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using UnityEditor;
namespace easyar
{
[CustomEditor(typeof(CloudRecognizerFrameFilter), true)]
public class CloudRecognizerFrameFilterEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if (!((CloudRecognizerFrameFilter)target).UseGlobalServiceConfig)
{
var keyType = serializedObject.FindProperty("ServerKeyType");
EditorGUILayout.PropertyField(keyType, true);
switch (keyType.enumValueIndex)
{
case (int)CloudRecognizerFrameFilter.KeyType.Public:
var apiServiceConfig = serializedObject.FindProperty("ServiceConfig");
apiServiceConfig.isExpanded = EditorGUILayout.Foldout(apiServiceConfig.isExpanded, "Service Config");
EditorGUI.indentLevel += 1;
if (apiServiceConfig.isExpanded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("ServiceConfig.ServerAddress"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("ServiceConfig.APIKey"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("ServiceConfig.APISecret"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("ServiceConfig.CloudRecognizerAppID"), true);
}
EditorGUI.indentLevel -= 1;
break;
case (int)CloudRecognizerFrameFilter.KeyType.Private:
var cloudServiceConfig = serializedObject.FindProperty("PrivateServiceConfig");
cloudServiceConfig.isExpanded = EditorGUILayout.Foldout(cloudServiceConfig.isExpanded, "Private Service Config");
EditorGUI.indentLevel += 1;
if (cloudServiceConfig.isExpanded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("PrivateServiceConfig.ServerAddress"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("PrivateServiceConfig.CloudRecognitionServiceSecret"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("PrivateServiceConfig.CloudRecognizerAppID"), true);
}
EditorGUI.indentLevel -= 1;
break;
default:
break;
}
}
serializedObject.ApplyModifiedProperties();
}
}
}
fileFormatVersion: 2
guid: b4165405a5165bf4dbc3545c6c6581a5
timeCreated: 1576549452
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
//================================================================================================================================
//
// Copyright (c) 2015-2021 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//================================================================================================================================
using System;
using UnityEditor;
using UnityEngine;
namespace easyar
{
[CustomEditor(typeof(ImageTargetController), true)]
public class ImageTargetControllerEditor : Editor
{
public void OnEnable()
{
var controller = (ImageTargetController)target;
UpdateScale(controller, controller.GizmoData.Scale);
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
var controller = (ImageTargetController)target;
switch (controller.SourceType)
{
case ImageTargetController.DataSource.ImageFile:
var imageFileSource = serializedObject.FindProperty("ImageFileSource");
imageFileSource.isExpanded = EditorGUILayout.Foldout(imageFileSource.isExpanded, "Image File Source");
EditorGUI.indentLevel += 1;
if (imageFileSource.isExpanded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("ImageFileSource.PathType"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("ImageFileSource.Path"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("ImageFileSource.Name"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("ImageFileSource.Scale"), true);
}
EditorGUI.indentLevel -= 1;
break;
case ImageTargetController.DataSource.TargetDataFile:
var targetDataFileSource = serializedObject.FindProperty("TargetDataFileSource");
targetDataFileSource.isExpanded = EditorGUILayout.Foldout(targetDataFileSource.isExpanded, "Target Data File Source");
EditorGUI.indentLevel += 1;
if (targetDataFileSource.isExpanded)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("TargetDataFileSource.PathType"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("TargetDataFileSource.Path"), true);
}
EditorGUI.indentLevel -= 1;
break;
default:
break;
}
var tracker = serializedObject.FindProperty("tracker");
EditorGUILayout.PropertyField(tracker, new GUIContent("Tracker"), true);
var trackerHasSet = serializedObject.FindProperty("trackerHasSet");
if (!trackerHasSet.boolValue)
{
if (!tracker.objectReferenceValue)
{
tracker.objectReferenceValue = FindObjectOfType<ImageTrackerFrameFilter>();
}
if (tracker.objectReferenceValue)
{
trackerHasSet.boolValue = true;
}
}
serializedObject.ApplyModifiedProperties();
controller.Tracker = (ImageTrackerFrameFilter)tracker.objectReferenceValue;
if (Event.current.type == EventType.Used)
{
foreach (var obj in DragAndDrop.objectReferences)
{
var objg = obj as GameObject;
if (objg && objg.GetComponent<ImageTrackerFrameFilter>() && !AssetDatabase.GetAssetPath(obj).Equals(""))
DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
}
}
CheckScale();
}
void CheckScale()
{
if (Application.isPlaying)
{
return;
}
var controller = (ImageTargetController)target;
if (controller.SourceType == ImageTargetController.DataSource.ImageFile)
{
if (controller.GizmoData.Scale != controller.ImageFileSource.Scale)
{
UpdateScale(controller, controller.ImageFileSource.Scale);
}
else if (controller.GizmoData.ScaleX != controller.transform.localScale.x)
{
controller.ImageFileSource.Scale = Math.Abs(controller.transform.localScale.x);
UpdateScale(controller, controller.ImageFileSource.Scale);
}
else if (controller.GizmoData.Scale != controller.transform.localScale.y)
{
controller.ImageFileSource.Scale = Math.Abs(controller.transform.localScale.y);
UpdateScale(controller, controller.ImageFileSource.Scale);
}
else if (controller.GizmoData.Scale != controller.transform.localScale.z)
{
controller.ImageFileSource.Scale = Math.Abs(controller.transform.localScale.z);
UpdateScale(controller, controller.ImageFileSource.Scale);
}
else if (controller.GizmoData.HorizontalFlip != controller.HorizontalFlip)
{
UpdateScale(controller, controller.ImageFileSource.Scale);
}
}
else
{
if (controller.GizmoData.HorizontalFlip != controller.HorizontalFlip || controller.GizmoData.ScaleX != controller.transform.localScale.x || controller.GizmoData.Scale != controller.transform.localScale.y || controller.GizmoData.Scale != controller.transform.localScale.z)
{
UpdateScale(controller, controller.GizmoData.Scale);
}
}
}
static private void UpdateScale(ImageTargetController controller, float s)
{
if (Application.isPlaying)
{
return;
}
var vec3Unit = Vector3.one;
if (controller.HorizontalFlip)
{
vec3Unit.x = -vec3Unit.x;
}
controller.transform.localScale = vec3Unit * s;
controller.GizmoData.Scale = s;
controller.GizmoData.ScaleX = controller.transform.localScale.x;
controller.GizmoData.HorizontalFlip = controller.HorizontalFlip;
}
[DrawGizmo(GizmoType.Active | GizmoType.Pickable | GizmoType.NotInSelectionHierarchy | GizmoType.InSelectionHierarchy)]
static void DrawGizmo(ImageTargetController scr, GizmoType gizmoType)
{
var signature = scr.SourceType.ToString();
switch (scr.SourceType)
{
case ImageTargetController.DataSource.ImageFile:
if (!EasyARController.Settings.GizmoConfig.ImageTarget.EnableImageFile) { return; }
signature += scr.ImageFileSource.PathType.ToString() + scr.ImageFileSource.Path;
break;
case ImageTargetController.DataSource.TargetDataFile:
if (!EasyARController.Settings.GizmoConfig.ImageTarget.EnableTargetDataFile) { return; }
signature += scr.TargetDataFileSource.PathType.ToString() + scr.TargetDataFileSource.Path;
break;
case ImageTargetController.DataSource.Target:
if (!EasyARController.Settings.GizmoConfig.ImageTarget.EnableTarget) { return; }
if (scr.Target != null)
{
signature += scr.Target.runtimeID().ToString();
}
break;
default:
break;
}
if (scr.GizmoData.Material == null)
{
scr.GizmoData.Material = new Material(Shader.Find("EasyAR/ImageTargetGizmo"));
}
if (scr.GizmoData.Signature != signature)
{
if (scr.GizmoData.Texture != null)
{
UnityEngine.Object.DestroyImmediate(scr.GizmoData.Texture);
scr.GizmoData.Texture = null;
}
string path;
switch (scr.SourceType)
{
case ImageTargetController.DataSource.ImageFile:
path = scr.ImageFileSource.Path;
if (scr.ImageFileSource.PathType == PathType.StreamingAssets)
{
path = Application.streamingAssetsPath + "/" + scr.ImageFileSource.Path;
}
if (System.IO.File.Exists(path))
{
var sourceData = System.IO.File.ReadAllBytes(path);
scr.GizmoData.Texture = new Texture2D(2, 2);
scr.GizmoData.Texture.LoadImage(sourceData);
scr.GizmoData.Texture.Apply();
UpdateScale(scr, scr.ImageFileSource.Scale);
if (SceneView.lastActiveSceneView)
{
SceneView.lastActiveSceneView.Repaint();
}
}
break;
case ImageTargetController.DataSource.TargetDataFile:
path = scr.TargetDataFileSource.Path;
if (scr.TargetDataFileSource.PathType == PathType.StreamingAssets)
{
path = Application.streamingAssetsPath + "/" + scr.TargetDataFileSource.Path;
}
if (System.IO.File.Exists(path))
{
if (!EasyARController.Initialized)
{
EasyARController.GlobalInitialization();
if (!EasyARController.Initialized)
{
Debug.LogWarning("EasyAR Sense target data gizmo enabled but license key validation failed, target data gizmo will not show");
}
}
var sourceData = System.IO.File.ReadAllBytes(path);
using (Buffer buffer = Buffer.wrapByteArray(sourceData))
{
var targetOptional = ImageTarget.createFromTargetData(buffer);
if (targetOptional.OnSome)
{
using (ImageTarget target = targetOptional.Value)
{
var imageList = target.images();
if (imageList.Count > 0)
{
var image = imageList[0];
scr.GizmoData.Texture = new Texture2D(image.width(), image.height(), TextureFormat.R8, false);
scr.GizmoData.Texture.LoadRawTextureData(image.buffer().data(), image.buffer().size());
scr.GizmoData.Texture.Apply();
}
foreach (var image in imageList)
{
image.Dispose();
}
UpdateScale(scr, target.scale());
if (SceneView.lastActiveSceneView)
{
SceneView.lastActiveSceneView.Repaint();
}
}
}
}
}
break;
case ImageTargetController.DataSource.Target:
if (scr.Target != null)
{
var imageList = (scr.Target as ImageTarget).images();
if (imageList.Count > 0)
{
var image = imageList[0];
scr.GizmoData.Texture = new Texture2D(image.width(), image.height(), TextureFormat.R8, false);
scr.GizmoData.Texture.LoadRawTextureData(image.buffer().data(), image.buffer().size());
scr.GizmoData.Texture.Apply();
}
foreach (var image in imageList)
{
image.Dispose();
}
UpdateScale(scr, (scr.Target as ImageTarget).scale());
if (SceneView.lastActiveSceneView)
{
SceneView.lastActiveSceneView.Repaint();
}
}
break;
default:
break;
}
if (scr.GizmoData.Texture == null)
{
scr.GizmoData.Texture = new Texture2D(2, 2);
scr.GizmoData.Texture.LoadImage(new byte[0]);
scr.GizmoData.Texture.Apply();
}
scr.GizmoData.Signature = signature;
}
if (scr.GizmoData.Material && scr.GizmoData.Texture)
{
scr.GizmoData.Material.SetMatrix("_Transform", scr.transform.localToWorldMatrix);
if (scr.GizmoData.Texture.format == TextureFormat.R8)
{
scr.GizmoData.Material.SetInt("_isRenderGrayTexture", 1);
}
else
{
scr.GizmoData.Material.SetInt("_isRenderGrayTexture", 0);
}
scr.GizmoData.Material.SetFloat("_Ratio", (float)scr.GizmoData.Texture.height / scr.GizmoData.Texture.width);
Gizmos.DrawGUITexture(new Rect(0, 0, 1, 1), scr.GizmoData.Texture, scr.GizmoData.Material);
}
}
}
}
fileFormatVersion: 2
guid: c3a6b6c45330c634f876acade7ffad5a
timeCreated: 1572726499
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment