本文整理汇总了C#中Space类的典型用法代码示例。如果您正苦于以下问题:C# Space类的具体用法?C# Space怎么用?C# Space使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Space类属于命名空间,在下文中一共展示了Space类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
using (var space = new Space())
{
}
}
示例2: OnRemovalFromSpace
/// <summary>
/// Called before an object is removed from its space.
/// </summary>
public override void OnRemovalFromSpace(Space oldSpace)
{
for (int i = 0; i < solverUpdateables.Count; i++)
{
solverUpdateables[i].OnRemovalFromSpace(oldSpace);
}
}
示例3: OnReset
public override void OnReset()
{
if (translation != null) {
translation.Value = Vector3.zero;
}
relativeTo = Space.Self;
}
示例4: Reset
public override void Reset()
{
gameObject = null;
moveVector = new FsmVector3 {UseVariable = true};
space = Space.World;
perSecond = true;
}
示例5: Awake
// Use this for initialization
void Awake()
{
Debug.Assert(SaveGameEventSubscription == null && AutoSaveGameEventSubscription == null);
SaveGameEventSubscription= MessageHub.Subscribe<SaveGameEvent>(SaveGame);
AutoSaveGameEventSubscription = MessageHub.Subscribe<AutoSaveGameEvent>(AutoSaveGame);
mapData = new CollectedMapData();
space = GameObject.Find("Space").GetComponent<Space>();
if (space == null)
{
throw new MissingComponentException("Unable to find Space. The big bang doesn't have enough space to happen. The 'Space' game object also needs to be added to the level and have the space script attached.");
}
airTrafficControl = GameObject.Find("AirTrafficControl").GetComponent<AirTrafficControl>();
if (space == null)
{
throw new MissingComponentException("Unable to find AirTrafficControl. There can't be any troops flying around without an global AirTrafficControl GameObject that has an AirTrafficControl Script attached.");
}
gameState = GameObject.Find("2D_MainCam").GetComponent<GameState>();
if (gameState == null)
{
throw new MissingComponentException("Unable to find GameState. The 'GameState' script needs to be attached to the same Gameobject as the BigBang.");
}
playerManager = GameObject.Find("PlayerManagement").GetComponent<PlayerManager>();
if (playerManager == null)
{
throw new MissingComponentException("Unable to find playerManager.");
}
}
示例6: SetZ
public static void SetZ(this Transform transform, float z, Space space = Space.Self)
{
if (space == Space.Self)
transform.localPosition = transform.localPosition.ScaleBy(1, 1, 0) + z*Vector3.forward;
else
transform.position = transform.position.ScaleBy(1, 1, 0) + z*Vector3.forward;
}
示例7: Done
public void Done()
{
if (SpaceName != null)
SpaceName = SpaceName.Trim();
if (string.IsNullOrWhiteSpace(SpaceName))
{
MessageBox.Show("Profile name is empty", "Locality", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (SpaceName.Length > 30)
{
MessageBox.Show("Profile name is too long", "Locality", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
foreach (var spc in App.Instance.Config.Spaces)
if (spc.Name.Equals(SpaceName, StringComparison.InvariantCultureIgnoreCase))
{
MessageBox.Show("This profile already exists", "Locality", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
var s = new Space { Name = SpaceName, Id = Guid.NewGuid().ToString() };
App.Instance.Config.Spaces.Add(s);
(Parent as RootViewModel).Back();
}
示例8: SetY
public static void SetY(this Transform transform, float y, Space space = Space.Self)
{
if (space == Space.Self)
transform.localPosition = transform.localPosition.ScaleBy(1, 0, 1) + y*Vector3.up;
else
transform.position = transform.position.ScaleBy(1, 0, 1) + y*Vector3.up;
}
示例9: Reset
public override void Reset()
{
this.gameObject = null;
this.space = Space.World;
this.storePosition = null;
this.everyFrame = false;
}
示例10: AttachGO
public void AttachGO(Transform dest, Transform source, Vector3 position, Quaternion rotation, Vector3 scale,
Space space = Space.Self)
{
if (source == null)
return;
if (dest == null)
{
source.parent = null;
}
else
{
source.parent = dest.transform;
}
if (space == Space.Self)
{
source.transform.localPosition = position;
source.transform.localRotation = rotation;
}
else
{
source.transform.position = position;
source.transform.rotation = rotation;
}
source.transform.localScale = scale;
}
示例11: Reset
public override void Reset()
{
gameObject = null;
space = Space.World;
storePosition = null;
everyFrame = false;
}
示例12: OnReset
public override void OnReset()
{
if (eulerAngles != null) {
eulerAngles.Value = Vector3.zero;
}
relativeTo = Space.Self;
}
示例13: Update
void Update()
{
if (!Application.isEditor)
{
Destroy(this);
return;
}
if (FreezePosition)
{
// Save current position if enabled
if ((FreezePosition != m_OldFreezePosition) || (space != m_OldSpace))
m_Position = (space == Space.World) ? transform.position : transform.localPosition;
// Freeze the position
if (space == Space.World)
transform.position = m_Position;
else
transform.localPosition = m_Position;
}
if (FreezeRotation)
{
// Save current rotation if enabled
if ((FreezeRotation != m_OldFreezeRotation) || (space != m_OldSpace))
m_Rotation = (space == Space.World) ? transform.rotation : transform.localRotation;
// Freeze the rotation
if (space == Space.World)
transform.rotation = m_Rotation;
else
transform.localRotation = m_Rotation;
}
m_OldSpace = space;
m_OldFreezePosition = FreezePosition;
m_OldFreezeRotation = FreezeRotation;
}
示例14: AddForce2D
/// <summary>
/// Function for applying a specific type of force to a Rigidbody2D (since the default functionality is incomplete)
/// </summary>
/// <param name="rb2d">Rigidbody2D to apply the force to</param>
/// <param name="force">The amount of force to apply</param>
/// <param name="mode">What type of force to apply</param>
/// <param name="relativeTo">Should the force be applied in the rigidbody's local space, or world space?</param>
public static void AddForce2D(this Rigidbody2D rb2d, Vector2 force, ForceMode mode = ForceMode.Force, Space relativeTo = Space.World)
{
ForceMode2D mode2D = ForceMode2D.Force;
Vector2 forceApplied = force;
switch (mode)
{
case ForceMode.Impulse:
mode2D = ForceMode2D.Impulse;
break;
case ForceMode.Acceleration:
forceApplied *= rb2d.mass;
break;
case ForceMode.VelocityChange:
forceApplied = force * rb2d.mass / Time.fixedDeltaTime;
break;
case ForceMode.Force:
//nothing special
break;
}
if (relativeTo == Space.Self)
rb2d.AddRelativeForce(forceApplied, mode2D);
else if (relativeTo == Space.World)
rb2d.AddForce(forceApplied, mode2D);
}
示例15: Reset
public override void Reset()
{
gameObject = null;
speed = null;
speedVector = null;
space = Space.World;
}