Commit 2017b3c8 authored by Valentin Burov's avatar Valentin Burov

poc_a

parent 074e01a7
......@@ -44,13 +44,9 @@ MonoBehaviour:
ContainsMagnet: 0
databaseLoad:
dataSetsToLoad:
- VuforiaMars_Images
- VuforiaMars_Object_OT
- VuforiaMars_VuMark
- stairtracker
dataSetsToActivate:
- VuforiaMars_Images
- VuforiaMars_Object_OT
- VuforiaMars_VuMark
- stairtracker
videoBackground:
clippingMode: 0
numDivisions: 2
......@@ -64,8 +60,8 @@ MonoBehaviour:
autoInitBuilder: 0
sceneUnitsToMillimeter: 0
deviceTracker:
autoInitTracker: 0
autoStartTracker: 0
autoInitTracker: 1
autoStartTracker: 1
trackingMode: 0
posePrediction: 0
modelCorrectionMode: 0
......
fileFormatVersion: 2
guid: cd8cf2559c099412f8169312b6df8c0e
folderAsset: yes
timeCreated: 1507422681
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 28e42327e3ca34f2eaa0c6973d8a6cc8
folderAsset: yes
timeCreated: 1507422681
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace SmartCopier
{
public class CopiedComponent
{
public Component Component { get; private set; }
public MemberCheckbox<PropertyInfo>[] PropertyCheckboxes { get; private set; }
public MemberCheckbox<FieldInfo>[] FieldCheckboxes { get; private set; }
public bool Checked { get; private set; }
private bool m_Foldout;
public CopiedComponent(Component component)
{
Component = component;
Checked = true;
Type tye = Component.GetType();
List<PropertyInfo> properties = tye.GetProperties(SmartCopier.Flags).ToList();
List<FieldInfo> fields = tye.GetFields(SmartCopier.Flags | BindingFlags.NonPublic).ToList();
FilterMembers(properties, fields);
PropertyCheckboxes = CreateMemberCheckboxes(properties);
FieldCheckboxes = CreateMemberCheckboxes(fields);
}
private static void FilterMembers(List<PropertyInfo> properties, List<FieldInfo> fields)
{
MemberFilter.FilterProperties(properties);
MemberFilter.FilterFields(fields);
}
private static MemberCheckbox<T>[] CreateMemberCheckboxes<T>(IList<T> members) where T : MemberInfo
{
MemberCheckbox<T>[] fieldCheckBoxes = new MemberCheckbox<T>[members.Count];
for (int i = 0; i < members.Count; ++i)
{
fieldCheckBoxes[i] = new MemberCheckbox<T>(members[i]);
}
return fieldCheckBoxes;
}
public void CopyTo(Component other)
{
foreach (MemberCheckbox<PropertyInfo> property in PropertyCheckboxes)
{
if (property.CanCopy())
{
PropertyInfo pi = property.Member;
pi.SetValue(other, pi.GetValue(Component, null), null);
}
}
foreach (MemberCheckbox<FieldInfo> field in FieldCheckboxes)
{
if (field.CanCopy())
{
FieldInfo fi = field.Member;
fi.SetValue(other, fi.GetValue(Component));
}
}
}
private void DrawProperties()
{
for (int i = 0; i < PropertyCheckboxes.Length; ++i)
{
PropertyCheckboxes[i].Draw();
}
}
private void DrawFields()
{
for (int i = 0; i < FieldCheckboxes.Length; ++i)
{
FieldCheckboxes[i].Draw();
}
}
public void Draw()
{
string componentName = Component.GetType().Name;
Texture icon = EditorGUIUtility.ObjectContent(Component, Component.GetType()).image;
GUIContent content = new GUIContent(icon);
content.text = componentName;
Checked = EditorGUILayout.ToggleLeft(content, Checked, SmartCopier.MainLabelStyle);
if (Checked)
{
m_Foldout = EditorGUILayout.Foldout(m_Foldout, componentName + " properties and fields");
if (m_Foldout)
{
++EditorGUI.indentLevel;
DrawProperties();
DrawFields();
--EditorGUI.indentLevel;
}
}
}
}
}
fileFormatVersion: 2
guid: 6262b5dd5334f28489465e4f5f33bc2b
timeCreated: 1449262024
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Reflection;
using UnityEditor;
namespace SmartCopier
{
public class MemberCheckbox<T> where T : MemberInfo
{
public T Member { get; private set; }
public bool Checked { get; set; }
public MemberCheckbox(T member)
{
Member = member;
Checked = IsAllowedToCopy();
}
public void Draw()
{
if (IsAllowedToCopy())
{
Checked = EditorGUILayout.ToggleLeft(Member.Name, Checked, SmartCopier.ListLabelStyle);
}
}
private bool IsAllowedToCopy()
{
return !MemberFilter.HasNoCopyAttribute(Member);
}
public bool CanCopy()
{
return IsAllowedToCopy() && Checked;
}
}
}
fileFormatVersion: 2
guid: 3a22c9335ff7ac9439ec0856bbba1535
timeCreated: 1449261921
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
namespace SmartCopier
{
public class MemberFilter
{
private static readonly List<PropertyInfo> m_FilterProperties = new List<PropertyInfo>();
private static void CreateFilters()
{
if (m_FilterProperties.Count == 0)
{
Type componentType = typeof(MonoBehaviour);
m_FilterProperties.AddRange(componentType.GetProperties(SmartCopier.Flags));
}
}
public static bool HasNoCopyAttribute(MemberInfo member)
{
return member.GetCustomAttributes(typeof (NoCopyAttribute), false).Length > 0;
}
private static bool CanFilterProperty(PropertyInfo property)
{
return !property.CanWrite ||
m_FilterProperties.Any(prop => prop.MetadataToken == property.MetadataToken);
}
private static bool CanFilterField(FieldInfo field)
{
object[] serializeFieldAttributes = field.GetCustomAttributes(typeof (SerializeField), false);
return !field.IsPublic && serializeFieldAttributes.Length == 0;
}
public static void FilterProperties(List<PropertyInfo> properties)
{
CreateFilters();
properties.RemoveAll(CanFilterProperty);
}
public static void FilterFields(List<FieldInfo> fields)
{
fields.RemoveAll(CanFilterField);
}
}
}
fileFormatVersion: 2
guid: e9ed9298637e7a64182ff6e403294c8e
timeCreated: 1449261983
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEditor;
using System;
using System.Linq;
using System.Reflection;
namespace SmartCopier
{
public class SmartCopier : EditorWindow
{
private enum CopyMode
{
ReplaceValues,
PasteAsNew
}
private const int Order = 10000000;
public static readonly BindingFlags Flags = BindingFlags.Instance | BindingFlags.Public;
public static GUIStyle MainLabelStyle { get; private set; }
public static GUIStyle ListLabelStyle { get; private set; }
private static GameObject m_GameObjectToCopyFrom;
private static CopiedComponent[] m_CopiedComponents;
private static Vector2 m_ScrollPosition;
private static CopyMode m_CopyMode;
[MenuItem("CONTEXT/Component/Smart Copy Components", false, Order)]
private static void ShowWindow(MenuCommand menuCommand)
{
m_GameObjectToCopyFrom = GetTargetObject(menuCommand);
BuildWindow();
}
[MenuItem("CONTEXT/Component/Smart Paste Components", false, Order + 1)]
private static void PasteComponents(MenuCommand menuCommand)
{
GameObject go = GetTargetObject(menuCommand);
PasteComponents(go);
}
[MenuItem("CONTEXT/Component/Smart Paste Components", true, Order + 1)]
private static bool ValidatePasteComponents(MenuCommand menuCommand)
{
return m_CopiedComponents != null && m_CopiedComponents.Length > 0 &&
GetTargetObject(menuCommand) != m_GameObjectToCopyFrom;
}
private void OnSelectionChange()
{
Repaint();
}
private static void BuildWindow()
{
Component[] components = m_GameObjectToCopyFrom.GetComponents<Component>();
CreateCopiedComponents(components);
GetWindow<SmartCopier>(false, "SmartCopier");
}
private static void PasteComponents(GameObject gameObject)
{
Undo.RecordObject(gameObject, "Copying components");
foreach (CopiedComponent copied in m_CopiedComponents.Where(c => c.Checked))
{
Type componentType = copied.Component.GetType();
if (m_CopyMode == CopyMode.PasteAsNew)
{
Component newComponent = Undo.AddComponent(gameObject, componentType);
if (newComponent != null)
{
EditorUtility.CopySerialized(copied.Component, newComponent);
Copy(copied, newComponent);
}
}
else
{
Component otherComponent = gameObject.GetComponent(componentType);
if (otherComponent == null)
{
otherComponent = Undo.AddComponent(gameObject, componentType);
}
Copy(copied, otherComponent);
}
EditorUtility.SetDirty(gameObject);
}
}
private static void Copy(CopiedComponent source, Component target)
{
// Try default Component copying first.
if (CanCopySerialized(source))
{
EditorUtility.CopySerialized(source.Component, target);
}
else // use custom copying logic.
{
source.CopyTo(target);
}
}
// If all checkboxes are checked, we can use Unity copying system.
private static bool CanCopySerialized(CopiedComponent copied)
{
return copied.PropertyCheckboxes.All(prop => prop.CanCopy()) &&
copied.FieldCheckboxes.All(field => field.CanCopy());
}
private bool HasCheckedAny()
{
for (int i = 0; i < m_CopiedComponents.Length; ++i)
{
CopiedComponent copied = m_CopiedComponents[i];
if (copied.Checked &&
(copied.PropertyCheckboxes.Any(prop => prop.CanCopy()) ||
copied.FieldCheckboxes.Any(field => field.CanCopy())))
{
return true;
}
}
return false;
}
private static GameObject GetTargetObject(MenuCommand menuCommand)
{
Component component = (Component)menuCommand.context;
return component.gameObject;
}
private static void CreateCopiedComponents(Component[] components)
{
m_CopiedComponents = new CopiedComponent[components.Length];
for (int i = 0; i < components.Length; ++i)
{
m_CopiedComponents[i] = new CopiedComponent(components[i]);
}
}
private static void CreateStyle()
{
MainLabelStyle = new GUIStyle(GUI.skin.label);
MainLabelStyle.fontStyle = FontStyle.Bold;
MainLabelStyle.padding = new RectOffset(5, MainLabelStyle.padding.right, MainLabelStyle.padding.top, MainLabelStyle.padding.bottom);
ListLabelStyle = new GUIStyle(GUI.skin.label);
ListLabelStyle.padding = MainLabelStyle.padding;
GUI.skin.label.wordWrap = true;
}
protected void OnGUI()
{
// Close the window if our data becomes invalid.
if (m_CopiedComponents == null)
{
GetWindow<SmartCopier>().Close();
return;
}
// Create the label styles once.
if (MainLabelStyle == null) CreateStyle();
m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
EditorGUILayout.Space();
EditorGUILayout.BeginHorizontal();
GUILayout.Label(string.Format("Select {0}'s Components and their properties to copy.", m_GameObjectToCopyFrom.name));
if (GUILayout.Button(new GUIContent("Refresh", "Refresh all components and properties in case components were added or removed.")))
{
BuildWindow();
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space();
DrawCopyMode();
EditorGUILayout.Space();
for (int i = 0; i < m_CopiedComponents.Length; ++i)
{
m_CopiedComponents[i].Draw();
EditorGUILayout.Space();
}
if (HasValidSelection())
{
if (HasCheckedAny())
{
GUILayout.Label("Press the button to copy the Components to the selected GameObjects.");
if (GUILayout.Button(new GUIContent("Smart Paste Components", "Paste all checked components and properties into the selected GameObjects."),
GUILayout.Height(30f)))
{
foreach (GameObject go in Selection.gameObjects)
{
PasteComponents(go);
}
}
}
else
{
GUILayout.Label("Check any Components or properties to copy them to the selected GameObjects.");
}
DrawSelectedGameObjects();
}
else
{
GUILayout.Label("Select GameObjects to copy the Components to.");
}
EditorGUILayout.Space();
EditorGUILayout.EndScrollView();
}
private static void DrawCopyMode()
{
GUILayout.BeginHorizontal();
m_CopyMode = (CopyMode)EditorGUILayout.EnumPopup(m_CopyMode, GUILayout.MaxWidth(100));
string label = m_CopyMode == CopyMode.PasteAsNew
? "Create new components with the selected properties."
: "Replace existing values, or create new.";
GUILayout.Label(label);
GUILayout.EndHorizontal();
}
private static void DrawSelectedGameObjects()
{
GUILayout.Label("Selected GameObjects:");
GUI.enabled = false;
GUI.color = new Color(1f, 1f, 1f, 1.25f);
foreach (GameObject go in Selection.gameObjects)
{
EditorGUILayout.ObjectField(go, go.GetType(), true);
}
GUI.color = Color.white;
GUI.enabled = true;
}
private static bool HasValidSelection()
{
GameObject[] selectedGameObjects = Selection.gameObjects;
return selectedGameObjects.Length > 0 &&
(selectedGameObjects.Length != 1 || selectedGameObjects[0] != m_GameObjectToCopyFrom);
}
}
}
fileFormatVersion: 2
guid: 4d05866111dea7849842507cf7755e9e
timeCreated: 1449169876
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
namespace SmartCopier
{
public class NoCopyAttribute : Attribute
{
}
}
fileFormatVersion: 2
guid: fa42575467f2ce74eb3525330825ca96
timeCreated: 1449314055
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Hi, thanks for using SmartCopier!
Use instructions:
1. Right-click any component in the inspector.
2. Click "Smart Copy Components" at the bottom of the context menu.
3. This will open the SmartCopier window where all of the GameObject's Components will be displayed.
4. Toggle any Component and their respective properties you wish to copy.
5. Select any amount of GameObjects you wish to copy the Components to and click "Smart Paste Components".
6. Alternatively, right click on any Component and click "Smart Paste Components" in the context menu.
You can add a [NoCopy] attribute above any property you do not wish to copy, like so:
[NoCopy]
public int Number;
This variable will not show up in the list of properties and fields of the SmartCopier window
and its value will not be copied.
fileFormatVersion: 2
guid: 3ed38e349ec9b324f89ee86c0143ae15
timeCreated: 1449271412
licenseType: Store
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: f22e986c4318c8440898c940d73f9a4f
folderAsset: yes
timeCreated: 1506489006
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: f22e986c4318c8440898c940d73f9a4f
guid: 1b9f16f1315c342ea838f74e04712958
folderAsset: yes
timeCreated: 1506489006
licenseType: Free
......
......@@ -6,7 +6,7 @@ Material:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: New Material
m_Name: VARchive first photogrammetry test material
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 4
......
......@@ -226,7 +226,7 @@ PlayerSettings:
androidSplashScreen: {fileID: 0}
AndroidKeystoreName:
AndroidKeyaliasName:
AndroidTVCompatibility: 1
AndroidTVCompatibility: 0
AndroidIsGame: 1
AndroidEnableTango: 0
androidEnableBanner: 1
......
AAAAGTpVgAf+mxs/rR2yGiNm9IKPXTsQGxSOoTjSHoU8avg4y1+vMZFlyGqYk1hbv8W9oNMVPiMYg4LC3HiMaq/vmU5ayLyI5DWLt3zYZPnLxOjNmQyS9l2WTgkped/s2CmNUhj+vkByRebZnfRNdgwV1GcfBs54Qy/kisVNjH0jUf9iC8Qu9u5cNBFdbP+SCG5bHPX5rAxloAEAjQ1zFs5F1G/Tt32Pjq6Z/gLS9GNFZmWFHIR6zyOtmw9dYejkhaOQc+D544lpSBCk6T+t4JRZa7Us8vghs3kteMFGMoizIXStchjoY23v0XqGIiZLB07uA0/W50r9MkS/4+PBWTm2P+k=
\ No newline at end of file
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