public SharedCrusherBase(ShareByCommon sharedBy) { this.shareBy = (SharedCrusherDefine.ShareBy)sharedBy; GetCallerTypeAndFieldName(); switch (this.shareBy) { case SharedCrusherDefine.ShareBy.ComponentAndFieldName: hashcode = (type.FullName + fieldname).GetHashCode(); return; case SharedCrusherDefine.ShareBy.FieldName: hashcode = fieldname.GetHashCode(); return; /// Prefabs can't immediately register with the SharedCrusherSO since they need to get their instanceId from the component, /// and StackTrace doesn't get us that. We get the instanceId from the Editor OnGui update. case SharedCrusherDefine.ShareBy.Prefab: return; default: UnityEngine.Debug.LogError("Invalid Enum value."); return; } }
/// <summary> /// Constructor that uses a supplied hashcode for identifying a shared crusher. If a crusher with this hascode has been constructed, /// then the existing crusher will be used. If not a new one will be instantiated and used. /// </summary> /// <param name="hashcode"></param> public SharedCrusherBase(int hashcode) { shareBy = SharedCrusherDefine.ShareBy.SpecifiedInt; GetCallerTypeAndFieldName(); this.hashcode = hashcode; }
/// <summary> /// Constructor that uses a supplied name as a hashcode for identifying a shared crusher. If a crusher with this hascode has been constructed, /// then the existing crusher will be used. If not a new one will be instantiated and used. /// </summary> /// <param name="hashcode"></param> public SharedCrusherBase(string name) { shareBy = SharedCrusherDefine.ShareBy.SpecifiedString; GetCallerTypeAndFieldName(); this.hashcode = name.GetHashCode(); }
/// <summary> /// Default constructor determines the type of the object that called the constructer, and uses a common crusher for all instances of that Type /// </summary> public SharedCrusherBase() { shareBy = SharedCrusherDefine.ShareBy.Prefab; GetCallerTypeAndFieldName(); }