public void OnEnable() { VuMarkAbstractBehaviour arg_22_0 = (VuMarkAbstractBehaviour)base.target; this.mSerializedObject = new SerializedVuMark(base.serializedObject); VuMarkEditor.EditorConfigureTarget(arg_22_0, this.mSerializedObject); }
private static void CheckMesh(SerializedVuMark serializedObject) { using (List <VuMarkAbstractBehaviour> .Enumerator enumerator = serializedObject.GetBehaviours().GetEnumerator()) { while (enumerator.MoveNext()) { GameObject gameObject = enumerator.Current.gameObject; MeshFilter component = gameObject.GetComponent <MeshFilter>(); if (component == null || component.sharedMesh == null) { VuMarkEditor.UpdateMesh(gameObject, serializedObject.BoundingBox, serializedObject.Origin); } } } if (!serializedObject.PreviewImageProperty.hasMultipleDifferentValues) { VuMarkEditor.UpdateMaterial(serializedObject); return; } UnityEngine.Object[] targetObjects = serializedObject.SerializedObject.targetObjects; for (int i = 0; i < targetObjects.Length; i++) { VuMarkEditor.UpdateMaterial(new SerializedVuMark(new SerializedObject(targetObjects[i]))); } }
public static void EditorConfigureTarget(VuMarkAbstractBehaviour vmb, SerializedVuMark serializedObject) { if (vmb == null) { Debug.LogError("VuMarkAbstractBehaviour parameter is null !"); return; } if (VuforiaUtilities.GetPrefabType(vmb) == PrefabType.Prefab) { return; } if (!SceneManager.Instance.SceneInitialized) { SceneManager.Instance.InitScene(); } using (serializedObject.Edit()) { if (!serializedObject.InitializedInEditor && !EditorApplication.isPlaying) { ConfigData.VuMarkData vuMarkData; ConfigDataManager.Instance.GetConfigData("--- EMPTY ---").GetVuMarkTarget("--- EMPTY ---", out vuMarkData); serializedObject.DataSetPath = "--- EMPTY ---"; serializedObject.TrackableName = "--- EMPTY ---"; VuMarkEditor.UpdateDataSetInfo(serializedObject, vuMarkData); VuMarkEditor.UpdateAspectRatio(serializedObject, vuMarkData.size); VuMarkEditor.UpdateScale(serializedObject, vuMarkData.size); serializedObject.InitializedInEditor = true; } } if (!EditorApplication.isPlaying) { VuMarkEditor.CheckMesh(serializedObject); } }
internal static void UpdateDataSetInfo(SerializedVuMark serializedObject, ConfigData.VuMarkData vuMarkInfo) { serializedObject.PreviewImage = "Assets/Editor/Vuforia/" + serializedObject.GetDataSetName() + "/" + vuMarkInfo.previewImage; serializedObject.IdType = vuMarkInfo.idType; serializedObject.IdLength = vuMarkInfo.idLength; Vector4 boundingBox2D = vuMarkInfo.boundingBox2D; serializedObject.BoundingBox = new Rect(boundingBox2D[0], boundingBox2D[1], boundingBox2D[2] - boundingBox2D[0], boundingBox2D[3] - boundingBox2D[1]); serializedObject.Origin = new Vector2(vuMarkInfo.origin.x, boundingBox2D[3] - vuMarkInfo.origin.y); }
internal static void UpdateAspectRatio(SerializedVuMark serializedObject, Vector2 size) { serializedObject.AspectRatio = size[1] / size[0]; using (List <VuMarkAbstractBehaviour> .Enumerator enumerator = serializedObject.GetBehaviours().GetEnumerator()) { while (enumerator.MoveNext()) { VuMarkEditor.UpdateMesh(enumerator.Current.gameObject, serializedObject.BoundingBox, serializedObject.Origin); } } }
internal static void UpdateScale(SerializedVuMark serializedObject, Vector2 size) { foreach (VuMarkAbstractBehaviour current in serializedObject.GetBehaviours()) { float num = current.GetSize()[0] / size[0]; if (serializedObject.AspectRatio <= 1f) { current.transform.localScale = new Vector3(size[0], size[0], size[0]); } else { current.transform.localScale = new Vector3(size[1], size[1], size[1]); } if (serializedObject.PreserveChildSize) { foreach (Transform transform in current.transform) { transform.localPosition = new Vector3(transform.localPosition.x * num, transform.localPosition.y * num, transform.localPosition.z * num); transform.localScale = new Vector3(transform.localScale.x * num, transform.localScale.y * num, transform.localScale.z * num); } } } }
internal static void UpdateMaterial(SerializedVuMark serializedObject) { Material material = serializedObject.GetMaterial(); string previewImage = serializedObject.PreviewImage; string trackableName = serializedObject.TrackableName; Material material2 = VuforiaUtilities.LoadReferenceMaterial(); if (material2 == null) { return; } Material material3 = material; if (material3 == null || material3 == material2) { material3 = new Material(material2); } Texture2D mainTexture = AssetDatabase.LoadAssetAtPath <Texture2D>(previewImage); material3.mainTexture = mainTexture; material3.mainTextureScale = new Vector2(1f, 1f); material3.name = trackableName + "Material"; serializedObject.SetMaterial(material3); }
public VuMarkAccessor(VuMarkAbstractBehaviour target) { this.mTarget = target; this.mSerializedObject = new SerializedVuMark(new SerializedObject(target)); }