本文整理汇总了C#中GameObject.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.GetHashCode方法的具体用法?C# GameObject.GetHashCode怎么用?C# GameObject.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject.GetHashCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: removeObject
public void removeObject(GameObject obj)
{
GridData data = objectToGridData[obj.GetHashCode()];
this.updateGrid(data.fromX, data.fromY, data.toX, data.toY, -data.cost);
objectToGridData.Remove(obj.GetHashCode());
//Debug.Log(string.Format("{0} at ({1},{2}) ({3}, {4})", obj.GetHashCode(), data.fromX, data.fromY, data.toX, data.toY));
}
示例2: findTarget
private UnitBase findTarget(GameObject target)
{
foreach (UnitBase unit in UnitHandler.units)
{
if (unit.unit.GetHashCode() == target.GetHashCode())
return unit;
}
return null;
}
示例3: GetID
public static string GetID(GameObject g)
{
foreach(KeyValuePair<string,GameObject> entry in objects) {
if (entry.Value.GetHashCode().Equals(g.GetHashCode())) {
return entry.Key;
break;
}
}
return "UnregisteredObject";
}
示例4: AddOnOutsideClickHandler
internal void AddOnOutsideClickHandler(GameObject gameObject, Action action)
{
int hashCode = gameObject.GetHashCode();
if (!_onOutsideClickHandlers.ContainsKey(hashCode))
{
_onOutsideClickHandlers.Add(hashCode, new ActionTracker(gameObject));
}
_onOutsideClickHandlers[hashCode].Add(action);
}
示例5: getUnit
public static Unit getUnit(GameObject gameObject)
{
int hashCode = gameObject.GetHashCode();
if (unitMap.ContainsKey(hashCode)){
return unitMap[hashCode];
}
else
{
return null;
}
}
示例6: registerObject
public void registerObject(GameObject obj, float x, float y, float width, float height, int cost)
{
GridData d = new GridData();
d.cost = cost;
d.xOffset = obj.transform.position.x - x;
d.yOffset = obj.transform.position.y - y;
getGridCoords(x - width/2, y - height/2, out d.fromX, out d.fromY);
getGridCoords(x + width/2, y + height/2, out d.toX, out d.toY);
objectToGridData[obj.GetHashCode()] = d;
this.updateGrid(d.fromX, d.fromY, d.toX, d.toY, cost);
//Debug.Log(string.Format("Registered object: {0} at ({1},{2}) ({3}, {4})", obj.GetHashCode(), d.fromX, d.fromY, d.toX, d.toY));
}
示例7: moveToPoint
public static IEnumerator moveToPoint(GameObject subject, Vector3 targetPoint)
{
MotionAgent motionAgent;
if (Instance.map.ContainsKey(subject.GetHashCode()))
{
motionAgent = Instance.map[subject.GetHashCode()];
if (motionAgent.navMeshObstacle.enabled)
{
motionAgent.navMeshObstacle.enabled = false;
yield return null;
yield return null;
}
if (!motionAgent.navMeshAgent.enabled)
{
motionAgent.navMeshAgent.enabled = true;
}
}
else
{
motionAgent = new MotionAgent(subject, targetPoint);
motionAgent.navMeshObstacle.enabled = false;
yield return null;
yield return null;
motionAgent.navMeshAgent.enabled = true;
Instance.map.Add(subject.GetHashCode(), motionAgent);
}
//Instance.agentList.Add(motionAgent);
motionAgent.isStop = false;
motionAgent.navMeshAgent.SetDestination(targetPoint);
yield return null;
Debug.Log(motionAgent.navMeshAgent.remainingDistance);
yield return motionAgent;
}
示例8: GameEntityCacheEntry
/// <summary>
/// Creates this cache entry
/// Automatically gets reference to the EntityTag of the Entity
/// </summary>
/// <param name="Entity">GameEntity to cache</param>
public GameEntityCacheEntry(GameObject Entity)
{
if(Entity.tag != "GameEntity")
{
Debug.LogError("Attempted to cache a non GameEntity GameObject. Blocked");
Entity = null;
Tag = null;
}
this.Entity = Entity;
Tag = Entity.GetComponent<EntityTag>();
EntityHash = Entity.GetHashCode();
}
示例9: updateObjectPosition
public void updateObjectPosition(GameObject obj)
{
GridData data = objectToGridData[obj.GetHashCode()];
// Remove old weight from old positions
this.updateGrid(data.fromX, data.fromY, data.toX, data.toY, -data.cost);
// calculate new positions
var width = data.toX - data.fromX;
var height = data.toY - data.fromY;
getGridCoords(obj.transform.position.x + data.xOffset - width/2, obj.transform.position.y + data.yOffset - height/2, out data.fromX, out data.fromY);
getGridCoords(obj.transform.position.x + data.xOffset + width/2, obj.transform.position.y + data.yOffset + height/2, out data.toX, out data.toY);
// update map
objectToGridData[obj.GetHashCode()] = data;
// Add weight to new positions
this.updateGrid(data.fromX, data.fromY, data.toX, data.toY, -data.cost);
//Debug.Log(string.Format("{0} at ({1},{2}) ({3}, {4})", obj.GetHashCode(), data.fromX, data.fromY, data.toX, data.toY));
}
示例10: HasGameObjectInHeirarchy
private bool HasGameObjectInHeirarchy(GameObject gameObject, int hashCodeToSearchFor)
{
if (gameObject.GetHashCode() == hashCodeToSearchFor)
return true;
foreach (Transform child in gameObject.transform)
{
if (HasGameObjectInHeirarchy(child.gameObject, hashCodeToSearchFor))
return true;
}
return false;
}
示例11: EvalutateOnOutsideClick
private void EvalutateOnOutsideClick(GameObject gameObjectBeingClicked)
{
int hashOfClickedItem = gameObjectBeingClicked.GetHashCode();
foreach (var kvp in _onOutsideClickHandlers)
{
// Create a strong reference to this variable so that it can't be collected after "HasExpired" evalutes
var gameObject = kvp.Value.GameObject;
if (!kvp.Value.HasExpired && !HasGameObjectInHeirarchy(gameObject, hashOfClickedItem))
{
kvp.Value.Execute();
}
}
}
示例12: RemoveSubject
/// <summary>
/// Removes a GameObject as a subjects of
/// this panel's transitions.
/// </summary>
/// <param name="go">GameObject to be removed as a subject.</param>
public void RemoveSubject(GameObject go)
{
int hash = go.GetHashCode();
if (!subjects.ContainsKey(hash))
return;
subjects.Remove(hash);
for (int i = 0; i < Transitions.list.Length; ++i)
Transitions.list[i].RemoveSubSubject(go);
// Remove the subject from any parent container as well:
if (container != null)
container.RemoveSubject(go);
}
示例13: AddSubject
/// <summary>
/// Adds a GameObject as a subject of this
/// panel's transitions.
/// </summary>
/// <param name="go">GameObject to be added as a subject.</param>
public void AddSubject(GameObject go)
{
int hash = go.GetHashCode();
if (subjects.ContainsKey(hash))
return;
subjects.Add(hash, go);
for (int i = 0; i < Transitions.list.Length; ++i)
Transitions.list[i].AddSubSubject(go);
// Add the subject to any parent container as well:
if (container != null)
container.AddSubject(go);
}
示例14: RemoveSubject
/// <summary>
/// Removes a GameObject as a subjects of
/// this panel's transitions.
/// </summary>
/// <param name="go">GameObject to be removed as a subject.</param>
public void RemoveSubject(GameObject go)
{
int hash = go.GetHashCode();
if (!subjects.ContainsKey(hash))
return;
subjects.Remove(hash);
for (int i = 0; i < Transitions.list.Length; ++i)
Transitions.list[i].RemoveSubSubject(go);
}
示例15: add
public static void add(GameObject gameObject,Unit unit)
{
unitMap.Add(gameObject.GetHashCode(), unit);
}