Exemplo n.º 1
0
        /// <summary>
        /// Checks for a child named "name" under the given parent, if it exists it is returned,
        /// else a new child is created with this name.
        /// </summary>
        static GameObject FindOrCreateGameObject(Transform parent,
                                                 SdfPath path,
                                                 Transform unityRoot,
                                                 PrimMap primMap,
                                                 SceneImportOptions options)
        {
            Transform  root = null;
            GameObject go   = null;
            string     name = path.GetName();

            if (parent == null)
            {
                go   = GameObject.Find(name);
                root = go ? go.transform : null;
            }
            else
            {
                root = parent.Find(name);
                go   = root ? root.gameObject : null;
            }

            if (!go)
            {
                // TODO: this should really not construct a game object if ImportHierarchy is false,
                // but it requires all downstream code be driven by the primMap instead of finding prims
                // via the usd scene. In addition, this requies the prim map to store lists of prims by
                // type, e.g. cameras, meshes, cubes, etc.
                go = new GameObject(name);
            }

            if (!go.GetComponent <UsdPrimSource>())
            {
                var ua = go.AddComponent <UsdPrimSource>();
                ua.m_usdPrimPath = path.ToString();
            }

            if (parent != null)
            {
                go.transform.SetParent(parent, worldPositionStays: false);
            }

            Profiler.BeginSample("Add to PrimMap");
            primMap[path] = go;
            Profiler.EndSample();
            return(go);
        }
Exemplo n.º 2
0
        protected bool IsMatch(SdfPath sdfPath)
        {
            string test = compareAgainst == ECompareAgainst.UsdName ? sdfPath.GetName() : sdfPath.ToString();

            return(isNot ? !m_regex.IsMatch(test) : m_regex.IsMatch(test));
        }