コード例 #1
0
ファイル: HUDIndicator.cs プロジェクト: sknchan/LegacyRust
    protected Vector3 GetPoint(HUDIndicator.PlacementSpace space, Vector3 input)
    {
        switch (space)
        {
        case HUDIndicator.PlacementSpace.World:
        {
            Camera  camera   = HUDIndicator.Target.camera;
            Vector3?nullable = CameraFX.World2Screen(input);
            input = camera.ScreenToWorldPoint((!nullable.HasValue ? Vector3.zero : nullable.Value));
            break;
        }

        case HUDIndicator.PlacementSpace.Screen:
        {
            input = HUDIndicator.Target.camera.ScreenToWorldPoint(input);
            break;
        }

        case HUDIndicator.PlacementSpace.Viewport:
        {
            input = HUDIndicator.Target.camera.ViewportToWorldPoint(input);
            break;
        }

        case HUDIndicator.PlacementSpace.Anchor:
        {
            input = this.anchor.transform.TransformPoint(input);
            break;
        }
        }
        return(input);
    }
コード例 #2
0
ファイル: HUDIndicator.cs プロジェクト: sknchan/LegacyRust
    private static HUDIndicator InstantiateIndicator(ref HUDIndicator.Target target, HUDIndicator prefab, HUDIndicator.PlacementSpace space, Vector3 position, float rotation)
    {
        UIAnchor   uIAnchor   = target.anchor;
        Quaternion quaternion = Quaternion.AngleAxis(rotation, Vector3.back);

        switch (space)
        {
        case HUDIndicator.PlacementSpace.World:
        {
            Camera  camera   = HUDIndicator.Target.camera;
            Vector3?nullable = CameraFX.World2Screen(position);
            position = camera.ScreenToWorldPoint((!nullable.HasValue ? Vector3.zero : nullable.Value));
            break;
        }

        case HUDIndicator.PlacementSpace.Screen:
        {
            position = HUDIndicator.Target.camera.ScreenToWorldPoint(position);
            break;
        }

        case HUDIndicator.PlacementSpace.Viewport:
        {
            position = HUDIndicator.Target.camera.ViewportToWorldPoint(position);
            break;
        }

        case HUDIndicator.PlacementSpace.Anchor:
        {
            position   = uIAnchor.transform.TransformPoint(position);
            quaternion = uIAnchor.transform.rotation * quaternion;
            break;
        }
        }
        position.z = uIAnchor.transform.position.z;
        HUDIndicator hUDIndicator = (HUDIndicator)UnityEngine.Object.Instantiate(prefab, position, quaternion);

        hUDIndicator.transform.parent     = uIAnchor.transform;
        hUDIndicator.transform.localScale = Vector3.one;
        hUDIndicator.anchor = target.anchor;
        return(hUDIndicator);
    }
コード例 #3
0
ファイル: HUDIndicator.cs プロジェクト: sknchan/LegacyRust
 protected static HUDIndicator InstantiateIndicator(HUDIndicator.ScratchTarget target, HUDIndicator prefab, HUDIndicator.PlacementSpace space, Vector3 position)
 {
     return(HUDIndicator.InstantiateIndicator(target, prefab, space, position, 0f));
 }
コード例 #4
0
ファイル: HUDIndicator.cs プロジェクト: sknchan/LegacyRust
 protected static HUDIndicator InstantiateIndicator(HUDIndicator.ScratchTarget target, HUDIndicator prefab, HUDIndicator.PlacementSpace space, Vector3 position, float rotation)
 {
     HUDIndicator.ScratchTarget scratchTarget = target;
     if (scratchTarget == HUDIndicator.ScratchTarget.CenteredAuto)
     {
         return(HUDIndicator.InstantiateIndicator(ref HUDIndicator.CenterAuto, prefab, space, position, rotation));
     }
     if (scratchTarget != HUDIndicator.ScratchTarget.CenteredFixed3000Tall)
     {
         throw new ArgumentOutOfRangeException("target");
     }
     return(HUDIndicator.InstantiateIndicator(ref HUDIndicator.CenterFixed3000Tall, prefab, space, position, rotation));
 }