/// <summary> /// Custom equals operator to take into account treePrototypes. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj == null) { return(prototypeObject == null); } System.Type instanceType = obj.GetType(); bool prototypeType = instanceType == typeof(TreePrototype); if (prototypeType) { TreePrototype instance = obj as TreePrototype; if (instance == null) { return(false); } return(instance.prefab == this.prototypeObject); } else { UNTreePrototype instance = obj as UNTreePrototype; if (instance == null) { return(false); } return(this.prototypeObject == instance.prototypeObject); } }
/// <summary> /// This method will pull the tree prototypes from the provided terrain data. /// </summary> void FetchTreePrototypes() { if (terrainData == null || terrainData.treePrototypes == null) { return; } if (!loadedIndexes) { } if (_treePrototypes == null) { _treePrototypes = new List <UNTreePrototype>(); } if (isDirty) { CheckForTreePrototypesChange(); } UNTreePrototype.CheckForMissings(_treePrototypes, terrainData.treePrototypes); #if UNITY_EDITOR UnityEditor.EditorUtility.SetDirty(this); #endif }
internal bool ContainsInPrototypes(UNTreePrototype prototype, List <TreePrototype> prototypes) { for (int i = 0; i < prototypes.Count; i++) { if (prototypes[i].prefab == prototype.prototypeObject) { return(true); } } return(false); }
/// <summary> /// Initiate startup variables /// </summary> protected override void Awake() { UNTreePrototype.CheckForMissings(terrainData.treePrototypes, terrain.terrainData.treePrototypes); var sectors = GetComponentsInChildren <UNTerrainSector>(); if (sectors.Length > 1) // if there's more than 1 sectors. { for (int i = 0; i < sectors.Length; i++) { GameObject.DestroyImmediate(sectors[i].gameObject); } _sector = null; } if (sector == null) { GenerateSector(sectorResolution); } if (Pool == null) { CreatePool(PoolItemType); } ThreadManager.InitializeIfNotAvailable(); // try to initialize if thread manager doesnt exist... if (!this.enabled) { return; } if (!Application.isPlaying) { return; } terrain = GetComponent <Terrain>(); base.Awake(); if (UNSettings.instance.UN_TreeInstancesRespawnsEnabled) { InvokeRepeating("CheckForTreeInstancesRespawns", 5, 5); } }