private GameObject GetOldestObject(List <GameObject> activeInstances) { float num = float.MaxValue; GameObject result = null; for (int i = 0; i < activeInstances.Count; i++) { PooledComponent component = activeInstances[i].GetComponent <PooledComponent>(); if (component != null) { if (component.SpawnTime < num) { num = component.SpawnTime; result = activeInstances[i]; } } else { Log.LogFatal(activeInstances[i], "Attempting to replace pooled instance based on lifetime (Oldest), however the game object or prefab is missing the required PooledLifetimeComponent!"); } } return(result); }
private static PooledComponent <Button> MakeSafePanel2(Transform parent, PooledComponent <Pvr_UnitySDKManager> sdkMgr) { var panel = MakePanel( parent, "SafePanel2", Vector3.zero, Quaternion.identity, 3 * Vector3.forward, 400, 400, new Color(27f / 255, 27f / 255, 27f / 255, 1)); panel.Ensure <GraphicRaycaster>(); MakeText( panel, "Title", 159 * Vector3.up, 200, 45, Vector3.one, 30, TextAnchor.MiddleCenter, new Color(1f, 0.57f, 0f)); MakeText( panel, "toast2", 5.3f * Vector3.up, 359, 132, Vector3.one, 25, TextAnchor.MiddleCenter, Color.white); var forceQuit = MakeImage( panel, "forcequitBtn", -82 * Vector3.up, 200, 35, ResourceExt.LoadAsset <Sprite>("Assets/PicoMobileSDK/Pvr_Controller/Texture/Bt_background_long1.png"), Image.Type.Sliced); var forceQuitButton = forceQuit.Ensure <Button>(); if (forceQuitButton.IsNew) { forceQuitButton.Value.interactable = true; forceQuitButton.Value.transition = Selectable.Transition.ColorTint; forceQuitButton.Value.targetGraphic = forceQuit.GetComponent <Image>(); forceQuitButton.Value.colors = new ColorBlock { normalColor = Color.white, highlightedColor = Color.blue, pressedColor = Color.red, disabledColor = Color.grey, colorMultiplier = 1, fadeDuration = 0.1f }; forceQuitButton.Value.navigation = new Navigation { mode = Navigation.Mode.Automatic }; } var forceQuitText = forceQuit .Ensure <RectTransform>("Text") .Ensure <Text>(); if (forceQuitText.IsNew) { forceQuitText.Value.font = ResourceExt.LoadAsset <Font>("Assets/PicoMobileSDK/Pvr_Controller/MicrosoftYaHeiGB.ttf"); forceQuitText.Value.fontStyle = FontStyle.Normal; forceQuitText.Value.fontSize = 20; forceQuitText.Value.lineSpacing = 1; forceQuitText.Value.supportRichText = true; forceQuitText.Value.alignment = TextAnchor.MiddleCenter; forceQuitText.Value.alignByGeometry = false; forceQuitText.Value.horizontalOverflow = HorizontalWrapMode.Wrap; forceQuitText.Value.verticalOverflow = VerticalWrapMode.Truncate; forceQuitText.Value.resizeTextForBestFit = false; forceQuitText.Value.color = new Color(50f / 255, 50f / 255, 50f / 255); forceQuitText.Value.raycastTarget = true; } if (forceQuitButton.IsNew || sdkMgr.IsNew) { forceQuitButton.Value.onClick.AddListener(sdkMgr.Value.SixDofForceQuit); } return(forceQuitButton); }