public void RemoveHierarchyGroup(EntityClassType _type) { HierarchyGroupObject _group = GetHierarchyGroup(_type); if (_group != null && _group.GroupTransform != null) { GameObject.DestroyImmediate(_group.GroupTransform.gameObject); } }
/// <summary> /// Adds the new hierarchy group by using the EntityClassType. /// </summary> /// <returns>The hierarchy group.</returns> /// <param name="_type">Type.</param> public HierarchyGroupObject AddHierarchyGroup(EntityClassType _type) { HierarchyGroupObject _group = null; if (GetHierarchyGroup(_type) == null) { _group = new HierarchyGroupObject(_type); HierarchyGroups.Add(_group); } return(_group); }
public HierarchyGroupObject GetHierarchyGroup(EntityClassType _type, bool _forced) { HierarchyGroupObject _group = GetHierarchyGroup(_type); if (_group == null && _forced) { _group = new HierarchyGroupObject(_type); HierarchyGroups.Add(_group); } return(_group); }
public HierarchyGroupObject AddHierarchyGroup(EntityClassType _type, bool _enabled) { HierarchyGroupObject _group = null; if (GetHierarchyGroup(_type) == null) { _group = new HierarchyGroupObject(_type); _group.Enabled = _enabled; HierarchyGroups.Add(_group); } return(_group); }
/// <summary> /// Updates the suffix. /// </summary> /// <param name="_suffix">Suffix.</param> public void UpdateSuffix(string _suffix) { if (_suffix == GroupSuffix) { return; } GroupSuffix = _suffix; foreach (EntityClassType _type in EntityClassTypes) { HierarchyGroupObject _group = UpdateHierarchyGroup(GetHierarchyGroup(_type, true)); if (_group != null) { _group.UpdateGroupName(GroupSuffix); } } }
/// <summary> /// Gets the hierarchy group transform. /// </summary> /// <returns>The hierarchy group transform.</returns> /// <param name="_type">Type.</param> public Transform GetHierarchyGroupTransform(EntityClassType _type) { if (!Enabled) { return(null); } HierarchyGroupObject _group = UpdateHierarchyGroup(GetHierarchyGroup(_type, true)); if (_group != null && _group.Enabled && _group.GroupTransform != null) { return(_group.GroupTransform); } else { return(GetHierarchyRootGroupTransform()); } }
public void UpdateHierarchyGroups(bool _modify_enabled, bool _enabled) { if (HierarchyRootGroup.GroupTransform == null) { HierarchyRootGroup.EntityType = EntityClassType.Undefined; HierarchyRootGroup.Enabled = _enabled; HierarchyRootGroup.GroupTransform = GetHierarchyRootGroupTransform(); } // this loop will get or create a group for each EntityClassType, updates all // data and acording to the _modify_enabled flag enable or disable the groups foreach (EntityClassType _type in EntityClassTypes) // System.Enum.GetValues( typeof(EntityClassType) ) ) { HierarchyGroupObject _group = UpdateHierarchyGroup(GetHierarchyGroup(_type, true)); if (_group != null && _modify_enabled) { _group.Enabled = _enabled; } } }
public HierarchyGroupObject UpdateHierarchyGroup(HierarchyGroupObject _group) { if (!Enabled || _group == null || !_group.Enabled) { return(null); } // this will be the name of the group object string _default_group_name = _group.EntityType.ToString() + GroupSuffix; // if the group have no transform we have to find a suitable object or we have // to create a new one if (_group.GroupTransform == null) { GameObject _obj = GameObject.Find(_default_group_name); if (_obj == null) { _group.GroupTransform = new GameObject().transform; _group.GroupTransform.SetParent(GetHierarchyRootGroupTransform(), true); _group.GroupTransform.name = _default_group_name; _group.GroupTransform.position = Vector3.zero; } else { _group.GroupTransform = _obj.transform; } } // if the group have a transform we have to set the correct parent // and update the name if required if (_group.GroupTransform != null) { _group.GroupTransform.SetParent(GetHierarchyRootGroupTransform(), true); } return(_group); }