Exemple #1
0
        public static void SetUp(Transform parentTransform)
        {
            visualFxGo = new GameObject("VisualFx");
            visualFxGo.transform.SetParent(parentTransform);
            Instance = visualFxGo.AddComponent <VisualFxManager>();
            if (!Application.isPlaying ||
                !AutomatedQARuntimeSettings.ActivatePlaybackVisualFx)
            {
                return;
            }

            canvasPoolGo = new GameObject("VisualFxCanvasObjectPool");
            canvasPoolGo.transform.SetParent(visualFxGo.transform);

            if (AutomatedQARuntimeSettings.ActivateClickFeedbackFx)
            {
                // Pre-make [preMakeRingCount] ring pulses to negate any performance impact from generating/destroying a lot of GameObjects in a short period.
                circleObjPoolGo = new GameObject("ClickPulseObjectPool");
                circleObjPoolGo.transform.SetParent(visualFxGo.transform);
                ringTexture2d = new Texture2D(2, 2);
                ringTexture2d.LoadImage(Convert.FromBase64String(ringBase64));
                for (int i = 0; i < preMakeRingCount; i++)
                {
                    PulseRings.Add(MakePulseRing());
                }

                // Also make canvas container objects. Around a fifth the total of pulse rings will be plenty.
                for (int i = 0; i < preMakeRingCount / 5; i++)
                {
                    VisualFxCanvases.Add(MakeVisualFxCanvas());
                }
            }

            if (AutomatedQARuntimeSettings.ActivateHighlightFeedbackFx)
            {
                // Pre-make [preMakeSquareCount] squares to negate any performance impact from generating/destroying a lot of GameObjects in a short period.
                squareObjPoolGo = new GameObject("HighlightSquareObjectPool");
                squareObjPoolGo.transform.SetParent(visualFxGo.transform);
                squareTexture2D = new Texture2D(2, 2);
                squareTexture2D.LoadImage(Convert.FromBase64String(squareBase64));
                for (int i = 0; i < preMakeSquareCount; i++)
                {
                    HighlightSquares.Add(MakeHighlightSquare());
                    VisualFxCanvases.Add(MakeVisualFxCanvas());
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Return square GameObject to the pool for later use.
 /// </summary>
 /// <param name="square">GameObject with RawImage of square</param>
 public static void ReturnHighlightSquare(GameObject square)
 {
     square.transform.SetParent(circleObjPoolGo.transform);
     square.SetActive(false);
     HighlightSquares.Add(square);
 }