Upgraded original RothenburgAR to Unity version 2017.4.5f1 (and upgrading from standalone vuforia to the version integrated in unity)
This commit is contained in:
65
Assets/Vuforia/Editor/Scripts/OpenSourceInitializer.cs
Normal file
65
Assets/Vuforia/Editor/Scripts/OpenSourceInitializer.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
/*===============================================================================
|
||||
Copyright (c) 2017 PTC Inc. All Rights Reserved.
|
||||
|
||||
Confidential and Proprietary - Protected under copyright and other laws.
|
||||
Vuforia is a trademark of PTC Inc., registered in the United States and other
|
||||
countries.
|
||||
===============================================================================*/
|
||||
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Vuforia;
|
||||
using Vuforia.EditorClasses;
|
||||
|
||||
/// <summary>
|
||||
/// Creates connection between open source files and the Vuforia library.
|
||||
/// Do not modify.
|
||||
/// </summary>
|
||||
[InitializeOnLoad]
|
||||
public static class OpenSourceInitializer
|
||||
{
|
||||
static OpenSourceInitializer()
|
||||
{
|
||||
GameObjectFactory.SetDefaultBehaviourTypeConfiguration(new DefaultBehaviourAttacher());
|
||||
ReplacePlaceHolders();
|
||||
}
|
||||
|
||||
static void ReplacePlaceHolders()
|
||||
{
|
||||
var trackablePlaceholders = Object.FindObjectsOfType<DefaultTrackableBehaviourPlaceholder>().ToList();
|
||||
var initErrorsPlaceholders = Object.FindObjectsOfType<DefaultInitializationErrorHandlerPlaceHolder>().ToList();
|
||||
|
||||
trackablePlaceholders.ForEach(ReplaceTrackablePlaceHolder);
|
||||
initErrorsPlaceholders.ForEach(ReplaceInitErrorPlaceHolder);
|
||||
}
|
||||
|
||||
static void ReplaceTrackablePlaceHolder(DefaultTrackableBehaviourPlaceholder placeHolder)
|
||||
{
|
||||
var go = placeHolder.gameObject;
|
||||
go.AddComponent<DefaultTrackableEventHandler>();
|
||||
|
||||
Object.DestroyImmediate(placeHolder);
|
||||
}
|
||||
|
||||
static void ReplaceInitErrorPlaceHolder(DefaultInitializationErrorHandlerPlaceHolder placeHolder)
|
||||
{
|
||||
var go = placeHolder.gameObject;
|
||||
go.AddComponent<DefaultInitializationErrorHandler>();
|
||||
|
||||
Object.DestroyImmediate(placeHolder);
|
||||
}
|
||||
|
||||
class DefaultBehaviourAttacher : IDefaultBehaviourAttacher
|
||||
{
|
||||
public void AddDefaultTrackableBehaviour(GameObject go)
|
||||
{
|
||||
go.AddComponent<DefaultTrackableEventHandler>();
|
||||
}
|
||||
|
||||
public void AddDefaultInitializationErrorHandler(GameObject go)
|
||||
{
|
||||
go.AddComponent<DefaultInitializationErrorHandler>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user