Material and textures on Windows and Doors appearing all white

38 Views Asked by At

Basically, I am helping to work on an application that allows users to create models of buildings and houses, then export those models into a mobile app that displays those models in the real world via AR. However, whenever doors or windows are attached to walls, they appear fine in the models before exporting, but when you see them via AR, they appear all white. I'm honestly pretty lost as to how to fix this issue, so I was hoping someone here would know.

Before exporting: enter image description here

After exporting: enter image description here

Possible Relevant Code:

SetRenderQueue.cs:


using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

[AddComponentMenu("Rendering/SetRenderQueue")]

public class SetRenderQueue : MonoBehaviour {

    public Shader wallShader;
    List<Renderer> walls = new List<Renderer>();

    [SerializeField]
    //protected int[] m_queues = new int[] { 3000 };

    protected void Awake() {
        Material[] materials = (from renderer in GetComponentsInChildren<Renderer>() select renderer.materials).SelectMany(i => i).ToArray();
        for (int i = 0; i < materials.Length; i++) {
            materials[i].renderQueue = 2500;
        }
    }

    private void FixedUpdate() {
        if (walls.Count != 0) {
            foreach (Renderer renderer in walls) {
                Material[] materials = renderer.materials;
                for (int i = 0; i < materials.Length; i++) {
                    materials[i].renderQueue = 2502;
                    //materials[i].shader = wallShader;
                }
            }
        }
    }
    void OnTriggerEnter(Collider other) {
        if (other.gameObject.tag == "Wall" || other.gameObject.tag == "RoofWall") {
            foreach (Renderer renderer in other.gameObject.GetComponentsInChildren<Renderer>()) {
                walls.Add(renderer);
                Material[] materials = renderer.materials;
                for (int i = 0; i < materials.Length; i++) {
                    materials[i].renderQueue = 2502;
                    //materials[i].shader = wallShader;
                }
            }
            other.gameObject.layer = 10;
            foreach(Transform wall in other.gameObject.transform) {
                wall.gameObject.layer = 10;
            }
        }
    }

}

Door_Window.cs:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(BoxCollider))]
[RequireComponent(typeof(CreateDepthMask))]
[RequireComponent(typeof(SetRenderQueue))]
public class Door_Window : Item
{
    public bool onFloor;
    public bool onWall;
    public bool onObject;
    public bool onCeiling;

    public DWType dwType;
    public Vector3 position;

    // Use this for initialization
    void Start() {

    }
    private void OnCollisionEnter(Collision collision) {
        if (collision.gameObject.tag == "Player") {
            gameObject.GetComponent<Collider>().enabled = false;
        }
    }

    private void OnCollisionExit(Collision collision) {
        if (collision.gameObject.tag == "Player") {
            gameObject.GetComponent<Collider>().enabled = true;
        }
    }
}
public enum DWType { Door, Window };

1

There are 1 best solutions below

0
On

Check the material property in AR app if the textures are there. I think it is more like a export script and/or shader problem.