protected override void Awake() {
     base.Awake();
     // placing this scaler above the UIPanel keeps Widget.onChange from firing every time the scale changes
     Profiler.BeginSample("Proper AddComponent allocation", gameObject);
     _scaler = _billboard.gameObject.AddComponent<ScaleRelativeToCamera>();
     Profiler.EndSample();
 }
Esempio n. 2
0
    private void FocusUI(bool shouldFocus)
    {
        if (scaleRelativeToCamera == null)
        {
            scaleRelativeToCamera
                = transform.Find("Tower UI(Clone)")
                  .GetComponent <ScaleRelativeToCamera>();
        }

        if (shouldFocus)
        {
            scaleRelativeToCamera.enabled = true;
        }
        else
        {
            scaleRelativeToCamera.enabled = false;
            scaleRelativeToCamera.ResetScale();
        }
    }
Esempio n. 3
0
 private void InitializeFleetIcon() {
     _fleetIconSprite = gameObject.GetSafeMonoBehaviourComponentInChildren<UISprite>();
     _fleetIconTransform = _fleetIconSprite.transform;
     _fleetIconScaler = _fleetIconTransform.gameObject.GetSafeMonoBehaviourComponent<ScaleRelativeToCamera>();
     // I need the collider sitting over the fleet icon to be 3D as it's rotation tracks the Cmd object, not the billboarded icon
     Vector2 iconSize = _fleetIconSprite.localSize;
     _iconSize = new Vector3(iconSize.x, iconSize.y, iconSize.x);
 }
Esempio n. 4
0
    private void InitializeFleetIcon() {
        _fleetIconSprite = gameObject.GetSafeFirstMonoBehaviourInChildren<UISprite>();
        _fleetIconTransform = _fleetIconSprite.transform;
        _fleetIconScaler = _fleetIconTransform.gameObject.GetSafeMonoBehaviour<ScaleRelativeToCamera>();
        _fleetCmdCollider = _fleetCmd.collider as BoxCollider;
        // I need the CmdCollider sitting over the fleet icon to be 3D as it's rotation tracks the Cmd object, not the billboarded icon
        Vector2 iconSize = _fleetIconSprite.localSize;
        _iconSize = new Vector3(iconSize.x, iconSize.y, iconSize.x);

        _iconFactory = AIconFactory.Instance;
        UpdateRate = FrameUpdateFrequency.Normal;
    }