private void UpdateProperties(NRSerializedImageTarget sit) { NRTrackableImageBehaviour itb = ((NRTrackableImageBehaviour)target); itb.TrackableName = m_ImagesName[m_SerializedObj.DatabaseIndex]; itb.DatabaseIndex = m_SerializedObj.DatabaseIndex; }
public void EditorDatabase(NRTrackableImageBehaviour itb, NRSerializedImageTarget serializedObj) { if (!NREditorSceneManager.Instance.SceneInitialized) { NREditorSceneManager.Instance.InitScene(); } if (!EditorApplication.isPlaying) { CheckMesh(serializedObj); } }
internal static void UpdateAspectRatio(NRSerializedImageTarget it) { Vector2 size = new Vector2(it.Width, it.Height); it.AspectRatio = size.y / size.x; using (List <NRTrackableImageBehaviour> .Enumerator enumerator = it.GetBehaviours().GetEnumerator()) { while (enumerator.MoveNext()) { UpdateMesh(enumerator.Current.gameObject, it.AspectRatio); } } }
/// <summary> Executes the 'enable' action. </summary> private void OnEnable() { NRTrackableImageBehaviour itb = (NRTrackableImageBehaviour)target; m_SerializedObj = new NRSerializedImageTarget(serializedObject); m_Database = GameObject.FindObjectOfType <NRSessionBehaviour>().SessionConfig.TrackingImageDatabase; if (m_Database == null) { return; } m_ImagesName = new string[m_Database.Count]; EditorDatabase(itb, m_SerializedObj); }
internal static void UpdateScale(NRSerializedImageTarget it) { Vector2 size = new Vector2(it.Width, it.Height); foreach (NRTrackableImageBehaviour item in it.GetBehaviours()) { if (it.AspectRatio <= 1f) // AspectRatio => y/x { item.transform.localScale = new Vector3(size.x, size.x, size.x) * 0.001f; } else { item.transform.localScale = new Vector3(size.y, size.y, size.y) * 0.001f; } } }
/// <summary> Updates the material described by sit. </summary> /// <param name="sit"> The sit.</param> internal static void UpdateMaterial(NRSerializedImageTarget sit) { Material mat = sit.GetMaterial(); Material loadMat = LoadMat(); if (mat == null || mat == loadMat) { mat = new Material(loadMat); } string name = m_ImagesName[sit.DatabaseIndex]; Texture2D texture = m_Database[sit.DatabaseIndex].Texture; mat.mainTexture = texture; mat.mainTextureScale = new Vector2(1f, 1f); mat.name = name + "Material"; sit.SetMaterial(mat); }
private void CheckMesh(NRSerializedImageTarget serializedImageTarget) { using (List <NRTrackableImageBehaviour> .Enumerator enumerator = serializedImageTarget.GetBehaviours().GetEnumerator()) { while (enumerator.MoveNext()) { GameObject go = enumerator.Current.gameObject; MeshFilter mf = go.GetComponent <MeshFilter>(); if ((mf == null || mf.sharedMesh == null) && serializedImageTarget.AspectRatioProperty.hasMultipleDifferentValues) { UpdateMesh(go, serializedImageTarget.AspectRatio); } } } if (!serializedImageTarget.TrackableNameProperty.hasMultipleDifferentValues) { UpdateMaterial(serializedImageTarget); } }
private static void UpdateAppearance(NRSerializedImageTarget serializedImageTarget) { UpdateAspectRatio(serializedImageTarget); UpdateScale(serializedImageTarget); UpdateMaterial(serializedImageTarget); }
public NRImageTargetAccessor(NRTrackableImageBehaviour target) { m_Target = target; m_SerializedObject = new NRSerializedImageTarget(new SerializedObject(m_Target)); }