コード例 #1
0
        private GameObject AddGameObjectGroup(SceneGroupType groupType, GameObject parentGameObject, FeatureMesh featureMesh)
        {
            GameObject gameObject = null;

            string name = featureMesh.GetName(groupType);

            // No name for this group in the feature, use the parent name
            if (name.Length == 0)
            {
                name = parentGameObject.name;
            }

            Transform transform = parentGameObject.transform.Find(name);

            if (transform == null)
            {
                // No children for this name, create a new game object
                gameObject = new GameObject(name);
                gameObject.transform.parent = parentGameObject.transform;
            }
            else
            {
                // Reuse the game object found the the group name in the hierarchy
                gameObject = transform.gameObject;
            }


            return(gameObject);
        }
コード例 #2
0
 public SceneGraph(GameObject regionMap, SceneGroupType groupOptions, GameObjectOptions gameObjectOptions, List <FeatureMesh> features)
 {
     this.gameObjectMeshData = new Dictionary <GameObject, MeshData>();
     this.regionMap          = regionMap;
     this.groupOptions       = groupOptions;
     this.gameObjectOptions  = gameObjectOptions;
     this.features           = features;
     this.leafGroup          = groupOptions.GetLeaf();
 }
コード例 #3
0
        /// <summary>
        /// Returns the leaf for the hierarchy of group type options
        /// </summary>
        /// <returns>The leaf type for the group options.</returns>
        /// <param name="options">The group type options.</param>
        public static SceneGroupType GetLeaf(this SceneGroupType options)
        {
            int enumCount = Enum.GetNames(typeof(SceneGroupType)).Length;
            int leftMost  = 1 << enumCount;

            while (!options.Includes((SceneGroupType)leftMost))
            {
                leftMost >>= 1;
            }

            return((SceneGroupType)leftMost);
        }
コード例 #4
0
        public string GetName(SceneGroupType groupType)
        {
            string name;

            switch (groupType)
            {
            case SceneGroupType.Feature: name = identifier; break;

            case SceneGroupType.Layer: name = layer; break;

            case SceneGroupType.Collection: name = collection; break;

            case SceneGroupType.Tile: name = tile; break;

            default: name = ""; break;
            }

            return(name);
        }
コード例 #5
0
 /// <summary>
 /// Tests whether this group is enabled in the group type options.
 /// </summary>
 /// <param name="type">The type to check.</param>
 /// <param name="options">The group type options.</param>
 public static bool Includes(this SceneGroupType options, SceneGroupType type)
 {
     return(((int)type & (int)options) == (int)type);
 }