FindObjectOfType() public static method

public static FindObjectOfType ( Type type ) : System.Object
type Type
return System.Object
Exemplo n.º 1
0
    public static T Get <T>()
    {
        object obj;

        objects.TryGetValue(typeof(T), out obj);

        if (obj == null)
        {
            if (typeof(Object).IsAssignableFrom(typeof(T)))
            {
                obj = Object.FindObjectOfType(typeof(T));
            }
            else
            {
                obj = Activator.CreateInstance <T>();
            }
            objects[typeof(T)] = obj;
        }

        return((T)obj);
    }
Exemplo n.º 2
0
 private void Awake()
 {
     _gameManager = Object.FindObjectOfType <GameManager>();
 }
Exemplo n.º 3
0
    private static Sprite TileSpriteAt(TilePosition tilePosition)
    {
        var wallStyle = Object.FindObjectOfType <WallTopStyle>();

        var r = tileMap.TileRoom(tilePosition);

        if (r != null)
        {
            if (r.Wall != null)
            {
                if (r.WithinPortal(tilePosition) && tileMap.TileRoom(tilePosition.Up) == null)
                {
                    // It's the top tile of a vertical portal between two rooms; make it be a wall
                    return(r.Wall.SingletonSprite);
                }

                if (tilePosition.Row == r.Bottom + r.Height - 1 && !r.IsBackWallTile(tilePosition))
                // It's the back wall
                {
                    if (r.WithinPortal(tilePosition.Right.Up))
                    {
                        return(r.Wall.RightSprite);
                    }
                    if (r.WithinPortal(tilePosition.Left.Up))
                    {
                        return(r.Wall.LeftSprite);
                    }
                    return(r.Wall.CenterSprite);
                }
            }
            return(r.Floor.Sprite);
        }

        // The tile isn't the interiod of a room.
        // Check to see if it's adjacent to a room.
        var upRoom        = TileMap.TheTileMap.TileRoom(tilePosition.Down);
        var downRoom      = TileMap.TheTileMap.TileRoom(tilePosition.Up);
        var leftRoom      = TileMap.TheTileMap.TileRoom(tilePosition.Left);
        var rightRoom     = TileMap.TheTileMap.TileRoom(tilePosition.Right);
        var upLeftRoom    = TileMap.TheTileMap.TileRoom(tilePosition.Down.Left);
        var upRightRoom   = TileMap.TheTileMap.TileRoom(tilePosition.Down.Right);
        var downLeftRoom  = TileMap.TheTileMap.TileRoom(tilePosition.Up.Left);
        var downRightRoom = TileMap.TheTileMap.TileRoom(tilePosition.Up.Right);


        var neighborsInRooms = (upRoom?Direction.Up:0)
                               | (downRoom?Direction.Down:0)
                               | (leftRoom ? Direction.Left : 0)
                               | (rightRoom ? Direction.Right : 0)
                               | (upLeftRoom ? Direction.UpLeft : 0)
                               | (upRightRoom ? Direction.UpRight : 0)
                               | (downLeftRoom ? Direction.DownLeft : 0)
                               | (downRightRoom ? Direction.DownRight : 0);

        switch (neighborsInRooms)
        {
        case Direction.None:
            return(null);

        case Direction.UpLeft:
            return(wallStyle.NECorner);

        case Direction.UpRight:
            return(wallStyle.NWCorner);

        case Direction.DownLeft:
            return(wallStyle.SECorner);

        case Direction.DownRight:
            return(wallStyle.SWCorner);

        case Direction.Up | Direction.Down | Direction.Left | Direction.Right:
            if (wallStyle.Cross != null)
            {
                return(wallStyle.Cross);
            }
            throw new InvalidOperationException("WallStyle does not include a tile for cross junctions");

        case Direction.UpLeft | Direction.UpRight:
        case Direction.UpLeft | Direction.UpRight | Direction.DownLeft | Direction.Down | Direction.DownRight:
            return(wallStyle.TJunctionDown);

        case Direction.DownLeft | Direction.DownRight:
        case Direction.DownLeft | Direction.DownRight | Direction.UpLeft | Direction.Up | Direction.UpRight:
            return(wallStyle.TJunctionUp);

        case Direction.UpLeft | Direction.DownLeft:
            return(wallStyle.TJunctionLeft);

        case Direction.UpRight | Direction.DownRight:
            return(wallStyle.TJunctionRight);

        case Direction.UpLeft /*| Direction.Up */ | Direction.UpRight
            | Direction.Right
            | Direction.DownRight | Direction.Down | Direction.DownLeft
            | Direction.Left:
            return(wallStyle.DownCap);

        case Direction.UpLeft | Direction.Up | Direction.UpRight
            | Direction.Right
            | Direction.DownRight /*| Direction.Down */ | Direction.DownLeft
            | Direction.Left:
            return(wallStyle.UpCap);

        case Direction.UpLeft | Direction.Up | Direction.UpRight
            /*| Direction.Right*/
            | Direction.DownRight | Direction.Down | Direction.DownLeft
            | Direction.Left:
        case Direction.UpLeft | Direction.Up     /*| Direction.UpRight*/
            /*| Direction.Right*/
            /*| Direction.DownRight*/ | Direction.Down | Direction.DownLeft
            | Direction.Left:
            return(wallStyle.RightCap);

        case Direction.UpLeft | Direction.Up | Direction.UpRight
            | Direction.Right
            | Direction.DownRight | Direction.Down | Direction.DownLeft
            /*| Direction.Left*/:
            return(wallStyle.LeftCap);

        default:
            if (upRoom || downRoom)
            {
                if (leftRoom)
                {
                    return(wallStyle.RightCap);
                }
                if (rightRoom)
                {
                    return(wallStyle.LeftCap);
                }
                return(wallStyle.Horizontal);
            }
            if (leftRoom || rightRoom)
            {
                return(wallStyle.Vertical);
            }
            return(null);
        }
    }
Exemplo n.º 4
0
 protected WorkerBase()
 {
     _pool = Object.FindObjectOfType <ThreadPoolHost>().Pool;         //Todo get rid of FindObjectOfType()
     _pool.AddWorker(this);
 }
Exemplo n.º 5
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            //if (property.propertyType != SerializedPropertyType.String)

            var soundManager = Object.FindObjectOfType <SoundManager>();
            var mixer        = soundManager.GetMixer();


            if (soundManager != null)
            {
                var keyList         = _GetExposedParameters(mixer).ToList();
                var currentKeyIndex = keyList.IndexOf(property.stringValue);
                var presented       = currentKeyIndex != -1;
                var controlID       = GUIUtility.GetControlID(FocusType.Passive);

                // label
                EditorGUI.LabelField(position, property.displayName);

                // apply selected
                if (ObjectPickerWindow.TryGetPickedObject(controlID, out string picked))
                {
                    property.stringValue = picked;
                }

                if (presented)
                {
                    // selection button
                    if (GUI.Button(new Rect(position.x + EditorGUIUtility.labelWidth, position.y, position.width - EditorGUIUtility.labelWidth, position.height), property.stringValue))
                    {
                        ObjectPickerWindow.Show(controlID, property.stringValue, keyList, 0, s => new GUIContent(s), "Select an exposed parameter");
                    }
                }
                else
                {
                    // change & save color
                    var tmpColor = GUI.backgroundColor;
                    GUI.backgroundColor = Color.red;

                    // selection button
                    if (GUI.Button(new Rect(position.x + EditorGUIUtility.labelWidth, position.y, position.width - EditorGUIUtility.labelWidth, position.height), property.stringValue))
                    {
                        ObjectPickerWindow.Show(controlID, property.stringValue,
                                                keyList, 0, s => new GUIContent(s), "Select an exposed parameter");
                    }

                    // restore bg color
                    GUI.backgroundColor = tmpColor;
                }

                // label click
                if (Event.current.type == EventType.ContextClick &&
                    new Rect(position.x, position.y, EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight)
                    .Contains(Event.current.mousePosition))
                {
                    // create context menu
                    var context = new GenericMenu();

                    // fill the menu, list could be large but for small projects, this is more convenient
                    foreach (var key in keyList)
                    {
                        context.AddItem(new GUIContent(key), key == property.stringValue, setKey, key);

                        // do not create lambda for all items
                        void setKey(object userData)
                        {
                            property.stringValue = (string)userData;
                            property.serializedObject.ApplyModifiedProperties();
                        }
                    }

                    // show menu
                    context.ShowAsContext();
                }
            }
            else
            {
                // show default string
                EditorGUI.PropertyField(position, property, true);
            }
        }
Exemplo n.º 6
0
        IEnumerator CollectGameObjects()
        {
            cameraMain = Camera.main;
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("cameraMain");

            dnaEvidences = Object.FindObjectsOfType <DNAEvidence>().ToList <DNAEvidence>();
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("dnaEvidences");

            doors = Object.FindObjectsOfType <Door>().ToList <Door>() ?? null;
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("doors");

            fuseBox = Object.FindObjectOfType <FuseBox>();
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("fuseBox");

            gameController = Object.FindObjectOfType <GameController>();
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("gameController");

            ghostAI = Object.FindObjectOfType <GhostAI>();
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("ghostAI");

            ghostAIs = Object.FindObjectsOfType <GhostAI>().ToList <GhostAI>();
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("ghostAIs");

            ghostActivity = Object.FindObjectOfType <GhostActivity>();
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("ghostActivity");

            ghostInfo = Object.FindObjectOfType <GhostInfo>();
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("ghostInfo");

            levelController = Object.FindObjectOfType <LevelController>();
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("levelController");

            ouijaBoards = Object.FindObjectsOfType <OuijaBoard>().ToList <OuijaBoard>();
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("ouijaBoards");

            if (Object.FindObjectOfType <Player>() != null)
            {
                player = Object.FindObjectOfType <Player>() ?? null;
                yield return(new WaitForSeconds(0.15f));

                Debug.Out("player");

                players = Object.FindObjectsOfType <Player>().ToList <Player>() ?? null;
                yield return(new WaitForSeconds(0.15f));

                Debug.Out("players");

                myPlayer = GetLocalPlayer() ?? player;
                Debug.Out("myPlayer");
                yield return(new WaitForSeconds(0.15f));

                playerAnim = myPlayer.field_Public_Animator_0 ?? null;
                yield return(new WaitForSeconds(0.15f));

                Debug.Out("playerAnim");

                if (playerAnim != null)
                {
                    boneTransform = playerAnim.GetBoneTransform(HumanBodyBones.Head) ?? null;
                    yield return(new WaitForSeconds(0.15f));

                    Debug.Out("boneTransform");
                    if (boneTransform != null)
                    {
                        light = boneTransform.GetComponent <Light>() ?? null;
                        yield return(new WaitForSeconds(0.15f));

                        Debug.Out("light");
                    }
                }
            }

            if (levelController != null)
            {
                photonView = ghostAI.field_Public_PhotonView_0 ?? null;
                yield return(new WaitForSeconds(0.15f));

                Debug.Out("photonView");
            }

            serverManager = Object.FindObjectOfType <ServerManager>();
            yield return(new WaitForSeconds(0.15f));

            Debug.Out("playerAnim");

            Debug.Out("-----------------------------");
            yield return(null);
        }
Exemplo n.º 7
0
 private static bool ValidateCreateTouchManager()
 {
     return(Object.FindObjectOfType <TCKInput>() == null);
 }
Exemplo n.º 8
0
        public IEnumerator Run(GraphicsTestCase testCase)
        {
#if UNITY_EDITOR
            while (SceneView.sceneViews.Count > 0)
            {
                var sceneView = SceneView.sceneViews[0] as SceneView;
                sceneView.Close();
            }
#endif
            SceneManagement.SceneManager.LoadScene(testCase.ScenePath);

            // Always wait one frame for scene load
            yield return(null);

            var testSettingsInScene    = Object.FindObjectOfType <GraphicsTestSettings>();
            var vfxTestSettingsInScene = Object.FindObjectOfType <VFXGraphicsTestSettings>();

            if (XRGraphicsAutomatedTests.enabled)
            {
                if (vfxTestSettingsInScene == null || vfxTestSettingsInScene.xrCompatible)
                {
                    XRGraphicsAutomatedTests.running = true;
                }
                else
                {
                    Assert.Ignore("Test scene is not compatible with XR and will be skipped.");
                }
            }

            //Setup frame rate capture
            float simulateTime     = VFXGraphicsTestSettings.defaultSimulateTime;
            int   captureFrameRate = VFXGraphicsTestSettings.defaultCaptureFrameRate;

            if (vfxTestSettingsInScene != null)
            {
                simulateTime     = vfxTestSettingsInScene.simulateTime;
                captureFrameRate = vfxTestSettingsInScene.captureFrameRate;
            }
            float period = 1.0f / captureFrameRate;

            Time.captureFramerate = captureFrameRate;
            UnityEngine.VFX.VFXManager.fixedTimeStep = period;
            UnityEngine.VFX.VFXManager.maxDeltaTime  = period;

            //Waiting for the capture frame rate to be effective
            const int maxFrameWaiting = 8;
            int       maxFrame        = maxFrameWaiting;
            while (Time.deltaTime != period && maxFrame-- > 0)
            {
                yield return(null);
            }
            Assert.Greater(maxFrame, 0);

            int captureSizeWidth  = 512;
            int captureSizeHeight = 512;
            if (testSettingsInScene != null)
            {
                captureSizeWidth  = testSettingsInScene.ImageComparisonSettings.TargetWidth;
                captureSizeHeight = testSettingsInScene.ImageComparisonSettings.TargetHeight;
            }

            var camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
            if (camera)
            {
                var vfxComponents = Resources.FindObjectsOfTypeAll <VisualEffect>();

                var rt = RenderTexture.GetTemporary(captureSizeWidth, captureSizeHeight, 24);
                camera.targetTexture = rt;

                //Waiting for the rendering to be ready, if at least one component has been culled, camera is ready
                maxFrame = maxFrameWaiting;
                while (vfxComponents.All(o => o.culled) && maxFrame-- > 0)
                {
                    yield return(null);
                }
                Assert.Greater(maxFrame, 0);

                foreach (var component in vfxComponents)
                {
                    component.Reinit();
                }

#if UNITY_EDITOR
                //When we change the graph, if animator was already enable, we should reinitialize animator to force all BindValues
                var animators = Resources.FindObjectsOfTypeAll <Animator>();
                foreach (var animator in animators)
                {
                    animator.Rebind();
                }
                var audioSources = Resources.FindObjectsOfTypeAll <AudioSource>();
#endif
                var paramBinders = Resources.FindObjectsOfTypeAll <VFXPropertyBinder>();
                foreach (var paramBinder in paramBinders)
                {
                    var binders = paramBinder.GetPropertyBinders <VFXBinderBase>();
                    foreach (var binder in binders)
                    {
                        binder.Reset();
                    }
                }

                int waitFrameCount     = (int)(simulateTime / period);
                int startFrameIndex    = Time.frameCount;
                int expectedFrameIndex = startFrameIndex + waitFrameCount;

                while (Time.frameCount != expectedFrameIndex)
                {
                    yield return(null);

#if UNITY_EDITOR
                    foreach (var audioSource in audioSources)
                    {
                        if (audioSource.clip != null && audioSource.playOnAwake)
                        {
                            audioSource.PlayDelayed(Mathf.Repeat(simulateTime, audioSource.clip.length));
                        }
                    }
#endif
                }

                Texture2D actual = null;
                try
                {
                    camera.targetTexture = null;
                    actual = new Texture2D(captureSizeWidth, captureSizeHeight, TextureFormat.RGB24, false);
                    RenderTexture.active = rt;
                    actual.ReadPixels(new Rect(0, 0, captureSizeWidth, captureSizeHeight), 0, 0);
                    RenderTexture.active = null;
                    actual.Apply();

                    var imageComparisonSettings = new ImageComparisonSettings()
                    {
                        AverageCorrectnessThreshold = VFXGraphicsTestSettings.defaultAverageCorrectnessThreshold
                    };
                    if (testSettingsInScene != null)
                    {
                        imageComparisonSettings.AverageCorrectnessThreshold = testSettingsInScene.ImageComparisonSettings.AverageCorrectnessThreshold;
                    }

                    ImageAssert.AreEqual(testCase.ReferenceImage, actual, imageComparisonSettings);
                }
                finally
                {
                    RenderTexture.ReleaseTemporary(rt);
                    if (actual != null)
                    {
                        UnityEngine.Object.Destroy(actual);
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Sets the option's value, it's not recommended to call this directly, call derivatives instead.
        /// </summary>
        /// <remarks>
        /// Does nothing when the value type differs or when the value matches the current value.
        /// </remarks>
        /// <param name="value">The new value</param>
        /// <param name="raiseEvents">Whether or not to raise events</param>
        private protected void SetValue(object value, bool raiseEvents)
        {
            if (value?.GetType() != Value?.GetType() || Value == value)
            {
                return;                                                         // Refuse value updates that don't match the option type
            }
            if (raiseEvents && OnValueChanged != null && AmongUsClient.Instance && PlayerControl.LocalPlayer && AmongUsClient.Instance.AmHost)
            {
                object lastValue = value;

                OptionOnValueChangedEventArgs args = OnValueChangedEventArgs(value, Value);
                foreach (EventHandler <OptionOnValueChangedEventArgs> handler in OnValueChanged.GetInvocationList())
                {
                    handler(this, args);

                    if (args.Value.GetType() != value.GetType())
                    {
                        args.Value  = lastValue;
                        args.Cancel = false;

                        EssentialsPlugin.Logger.LogWarning($"A handler for option \"{Name}\" attempted to change value type, ignored.");
                    }

                    lastValue = args.Value;

                    if (args.Cancel)
                    {
                        return;              // Handler cancelled value change.
                    }
                }

                value = args.Value;
            }

            if (OldValue != Value)
            {
                OldValue = Value;
            }

            Value = value;

            if (GameSetting != null && AmongUsClient.Instance && PlayerControl.LocalPlayer && AmongUsClient.Instance.AmHost)
            {
                Rpc.Instance.Send(new Rpc.Data(this));
            }

            try
            {
                if (GameSetting is ToggleOption toggle)
                {
                    bool newValue = (bool)Value;

                    toggle.oldValue = newValue;
                    if (toggle.CheckMark != null)
                    {
                        toggle.CheckMark.enabled = newValue;
                    }
                }
                else if (GameSetting is NumberOption number)
                {
                    float newValue = (float)Value;

                    number.Value          = number.oldValue = newValue;
                    number.ValueText.Text = ToString();
                }
                else if (GameSetting is StringOption str)
                {
                    int newValue = (int)Value;

                    str.Value          = str.oldValue = newValue;
                    str.ValueText.Text = ToString();
                }
                else if (GameSetting is KeyValueOption kv)
                {
                    int newValue = (int)Value;

                    kv.Selected       = kv.oldValue = newValue;
                    kv.ValueText.Text = ToString();
                }
            }
            catch (Exception e)
            {
                EssentialsPlugin.Logger.LogWarning($"Failed to update game setting value for option \"{Name}\": {e}");
            }

            if (raiseEvents)
            {
                ValueChanged?.Invoke(this, ValueChangedEventArgs(value, Value));
            }

            /*{
             *  OptionValueChangedEventArgs args = ValueChangedEventArgs(value, Value);
             *  foreach (EventHandler<OptionValueChangedEventArgs> handler in ValueChanged.GetInvocationList()) handler(this, args);
             * }*/

            try
            {
                if (GameSetting != null)
                {
                    Object.FindObjectOfType <GameOptionsMenu>()?.Method_16();                     // RefreshChildren();
                }
            }
            catch
            {
            }
        }
Exemplo n.º 10
0
        public static void SetupSmartShowButtons(object value, TypeUtil.SmartType smartType)
        {
            if (smartType == TypeUtil.SmartType.Undefined || value == null || value.GetType().IsArray)
            {
                return;
            }

            try
            {
                switch (smartType)
                {
                case TypeUtil.SmartType.Sprite:
                {
                    if (!(value is string stringValue) || !UIView.GetAView().defaultAtlas.spriteNames.Contains(stringValue))
                    {
                        return;
                    }

                    if (GUILayout.Button("Show sprite"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForSprite(stringValue));
                    }

                    break;
                }

                case TypeUtil.SmartType.ParkedVehicle:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show parked vehicle"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForParkedVehicle(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.Vehicle:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show vehicle"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForVehicle(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.Building:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show building"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForBuilding(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.CitizenUnit:
                {
                    if (Convert.ToUInt32(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show citizen unit"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForCitizenUnit(Convert.ToUInt32(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.Citizen:
                {
                    if (Convert.ToUInt32(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show citizen"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForCitizen(Convert.ToUInt32(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.TransportLine:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show transport line"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForTransportLine(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.PathUnit:
                {
                    if (Convert.ToUInt32(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show path unit"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForPathUnit(Convert.ToUInt32(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.NetNode:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show network node"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForNode(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.NetSegment:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show network segment"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForSegment(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.NetLane:
                {
                    if (Convert.ToUInt32(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show network lane"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForLane(Convert.ToUInt32(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.ParkDistrict:
                {
                    if (Convert.ToByte(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show park district"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForPark(Convert.ToByte(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.District:
                {
                    if (Convert.ToByte(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show district"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForDistrict(Convert.ToByte(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.Tree:
                {
                    if (Convert.ToUInt32(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show tree"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForTree(Convert.ToUInt32(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.Prop:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show prop"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForProp(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.CitizenInstance:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show citizen instance"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForCitizenInstance(Convert.ToUInt16(value)));
                    }

                    break;
                }

                case TypeUtil.SmartType.ZoneBlock:
                {
                    if (Convert.ToUInt16(value) < 1)
                    {
                        return;
                    }

                    if (GUILayout.Button("Show zone block"))
                    {
                        var sceneExplorer = Object.FindObjectOfType <SceneExplorer>();
                        sceneExplorer.Show(ReferenceChainBuilder.ForZoneBlock(Convert.ToUInt16(value)));
                    }

                    break;
                }

                default:
                    return;
                }
            }
            catch
            {
                // suppress
            }
        }
Exemplo n.º 11
0
        private void AddSpriteNameForGroup(ItemGroup group, string spriteName)
        {
            var spriteStore = Object.FindObjectOfType <SpriteStore>();

            switch (group)
            {
            case ItemGroup.Robe:
                //todo
                break;

            case ItemGroup.Armor:
                //todo
                break;

            case ItemGroup.Feet:
                //todo
                break;

            case ItemGroup.Glove:
                //todo
                break;

            case ItemGroup.Helmet:
                //todo
                break;

            case ItemGroup.Ring:
                //todo
                break;

            case ItemGroup.Shield:
                spriteStore.ShieldSpriteNames.Add(spriteName);
                break;

            case ItemGroup.Axe:
                //todo
                break;

            case ItemGroup.Crossbow:
                spriteStore.CrossbowSpriteNames.Add(spriteName);
                break;

            case ItemGroup.Dagger:
                spriteStore.DaggerSpriteNames.Add(spriteName);
                break;

            case ItemGroup.OneHandedSpear:
            case ItemGroup.TwoHandedSpear:
                spriteStore.SpearSpriteNames.Add(spriteName);
                break;

            case ItemGroup.Book:
                //todo
                break;

            case ItemGroup.OneHandedSword:
            case ItemGroup.TwoHandedSword:
                spriteStore.SwordSpriteNames.Add(spriteName);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(@group), @group, null);
            }
        }
Exemplo n.º 12
0
        public IEnumerator Run(GraphicsTestCase testCase)
        {
#if UNITY_EDITOR
            while (SceneView.sceneViews.Count > 0)
            {
                var sceneView = SceneView.sceneViews[0] as SceneView;
                sceneView.Close();
            }
#endif
            SceneManagement.SceneManager.LoadScene(testCase.ScenePath);

            // Always wait one frame for scene load
            yield return(null);

            var testSettingsInScene    = Object.FindObjectOfType <GraphicsTestSettings>();
            var vfxTestSettingsInScene = Object.FindObjectOfType <VFXGraphicsTestSettings>();

            //Setup frame rate capture
            float simulateTime     = VFXGraphicsTestSettings.defaultSimulateTime;
            int   captureFrameRate = VFXGraphicsTestSettings.defaultCaptureFrameRate;

            if (vfxTestSettingsInScene != null)
            {
                simulateTime     = vfxTestSettingsInScene.simulateTime;
                captureFrameRate = vfxTestSettingsInScene.captureFrameRate;
            }
            float frequency = 1.0f / captureFrameRate;

            Time.captureFramerate = captureFrameRate;
            UnityEngine.VFX.VFXManager.fixedTimeStep = frequency;
            UnityEngine.VFX.VFXManager.maxDeltaTime  = frequency;

            int captureSizeWidth  = 512;
            int captureSizeHeight = 512;
            if (testSettingsInScene != null)
            {
                captureSizeWidth  = testSettingsInScene.ImageComparisonSettings.TargetWidth;
                captureSizeHeight = testSettingsInScene.ImageComparisonSettings.TargetHeight;
            }

            var camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
            if (camera)
            {
                var vfxComponents = Resources.FindObjectsOfTypeAll <VisualEffect>();
#if UNITY_EDITOR
                var vfxAssets = vfxComponents.Select(o => o.visualEffectAsset).Where(o => o != null).Distinct();
                foreach (var vfx in vfxAssets)
                {
                    //Use Reflection as workaround of the access issue in .net 4 (TODO : Clean this as soon as possible)
                    //var graph = vfx.GetResource().GetOrCreateGraph(); is possible with .net 3.5 but compilation fail with 4.0
                    var visualEffectAssetExt = AppDomain.CurrentDomain.GetAssemblies().Select(o => o.GetType("UnityEditor.VFX.VisualEffectAssetExtensions"))
                                               .Where(o => o != null)
                                               .FirstOrDefault();
                    var fnGetResource = visualEffectAssetExt.GetMethod("GetResource");
                    fnGetResource = fnGetResource.MakeGenericMethod(new Type[] { typeof(VisualEffectAsset) });
                    var resource = fnGetResource.Invoke(null, new object[] { vfx });
                    if (resource == null)
                    {
                        continue; //could occurs if VisualEffectAsset is in AssetBundle
                    }
                    var fnGetOrCreate = visualEffectAssetExt.GetMethod("GetOrCreateGraph");
                    var graph         = fnGetOrCreate.Invoke(null, new object[] { resource }) as VFXGraph;
                    graph.RecompileIfNeeded();
                }
#endif

                var rt = RenderTexture.GetTemporary(captureSizeWidth, captureSizeHeight, 24);
                camera.targetTexture = rt;

                foreach (var component in vfxComponents)
                {
                    component.Reinit();
                }

#if UNITY_EDITOR
                //When we change the graph, if animator was already enable, we should reinitialize animator to force all BindValues
                var animators = Resources.FindObjectsOfTypeAll <Animator>();
                foreach (var animator in animators)
                {
                    animator.Rebind();
                }
                var audioSources = Resources.FindObjectsOfTypeAll <AudioSource>();
#endif
                var paramBinders = Resources.FindObjectsOfTypeAll <VFXPropertyBinder>();
                foreach (var paramBinder in paramBinders)
                {
                    var binders = paramBinder.GetParameterBinders <VFXBinderBase>();
                    foreach (var binder in binders)
                    {
                        binder.Reset();
                    }
                }

                int waitFrameCount     = (int)(simulateTime / frequency);
                int startFrameIndex    = Time.frameCount;
                int expectedFrameIndex = startFrameIndex + waitFrameCount;
                while (Time.frameCount != expectedFrameIndex)
                {
                    yield return(null);

#if UNITY_EDITOR
                    foreach (var audioSource in audioSources)
                    {
                        if (audioSource.clip != null && audioSource.playOnAwake)
                        {
                            audioSource.PlayDelayed(Mathf.Repeat(simulateTime, audioSource.clip.length));
                        }
                    }
#endif
                }

                Texture2D actual = null;
                try
                {
                    camera.targetTexture = null;
                    actual = new Texture2D(captureSizeWidth, captureSizeHeight, TextureFormat.RGB24, false);
                    RenderTexture.active = rt;
                    actual.ReadPixels(new Rect(0, 0, captureSizeWidth, captureSizeHeight), 0, 0);
                    RenderTexture.active = null;
                    actual.Apply();

                    var imageComparisonSettings = new ImageComparisonSettings()
                    {
                        AverageCorrectnessThreshold = 5e-4f
                    };
                    if (testSettingsInScene != null)
                    {
                        imageComparisonSettings.AverageCorrectnessThreshold = testSettingsInScene.ImageComparisonSettings.AverageCorrectnessThreshold;
                    }

                    if (!ExcludedTestsButKeepLoadScene.Any(o => testCase.ScenePath.Contains(o)) &&
                        !(SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal && UnstableMetalTests.Any(o => testCase.ScenePath.Contains(o))))
                    {
                        ImageAssert.AreEqual(testCase.ReferenceImage, actual, imageComparisonSettings);
                    }
                    else
                    {
                        Debug.LogFormat("GraphicTest '{0}' result has been ignored", testCase.ReferenceImage);
                    }
                }
                finally
                {
                    RenderTexture.ReleaseTemporary(rt);
                    if (actual != null)
                    {
                        UnityEngine.Object.Destroy(actual);
                    }
                }
            }
        }
Exemplo n.º 13
0
        public TimelineAsset[] m_assets;//实现在Inspector面板的显示

        public override void SingletonInit()
        {
            m_TimelinePlayer = Object.FindObjectOfType <PlayableDirector>();
            //m_timelineAssetDic.Add(TimelineEnum.Default, m_assets[0] != null ? m_assets[0] : null);
            //m_timelineAssetDic.Add(TimelineEnum.StartScene, m_assets[1] != null ? m_assets[1] : null);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initialization method for setting up the simulation network
        /// </summary>
        /// <param name="simulationId">This machine simulation id</param>
        /// <param name="clusterData">Cluster data for this simulation</param>
        /// <param name="settings">Settings used in this simulation</param>
        public void Initialize(string simulationId, ClusterData clusterData, NetworkSettings settings)
        {
            ClusterData = clusterData;
            Settings    = settings;

            //Check what cluster node type is this machine in the simulation
            if (ClusterData.Instances.Length <= 1)
            {
                Type = ClusterNodeType.NotClusterNode;
            }
            else
            {
                //Set this machine type
                var instancesData = ClusterData.Instances.Where(instance => instance.SimId == simulationId).ToArray();
                var resultsCount  = instancesData.Length;
                if (resultsCount == 0)
                {
                    throw new ArgumentException(
                              $"Invalid cluster settings. Could not find instance data for the simulation id '{simulationId}'.");
                }
                if (resultsCount > 1)
                {
                    throw new ArgumentException(
                              $"Invalid cluster settings. Found multiple instance data for the simulation id '{simulationId}'.");
                }
                var thisInstanceData = instancesData[0];
                Type            = thisInstanceData.IsMaster ? ClusterNodeType.Master : ClusterNodeType.Client;
                LocalIdentifier = thisInstanceData.SimId;
                foreach (var ip in thisInstanceData.Ip)
                {
                    LocalAddresses.Add(new IPEndPoint(IPAddress.Parse(ip), Settings.ConnectionPort));
                }

                //Setup master addresses
                var masterInstanceData = ClusterData.Instances.Where(instance => instance.IsMaster).ToArray();
                resultsCount = masterInstanceData.Length;
                if (resultsCount == 0)
                {
                    throw new ArgumentException($"Invalid cluster settings. Could not find master instance data.");
                }
                if (resultsCount > 1)
                {
                    throw new ArgumentException($"Invalid cluster settings. Found multiple master instance data.");
                }
                MasterIdentifier = masterInstanceData[0].SimId;
                foreach (var ip in masterInstanceData[0].Ip)
                {
                    MasterAddresses.Add(new IPEndPoint(IPAddress.Parse(ip), Settings.ConnectionPort));
                }
            }

            //Initialize network objects
            var mainThreadDispatcher = Object.FindObjectOfType <MainThreadDispatcher>();

            if (mainThreadDispatcher == null)
            {
                var dispatcher = new GameObject("MainThreadDispatcher");
                Object.DontDestroyOnLoad(dispatcher);
                dispatcher.AddComponent <MainThreadDispatcher>();
            }
            if (Type == ClusterNodeType.Master)
            {
                var masterGameObject = new GameObject("MasterManager");
                Object.DontDestroyOnLoad(masterGameObject);
                Master = masterGameObject.AddComponent <MasterManager>();
                Master.SetSettings(Settings);
                var clientsIdentifiers = ClusterData.Instances.Where(instanceData => !instanceData.IsMaster)
                                         .Select(instanceData => instanceData.SimId).ToList();
                Master.StartConnection(clientsIdentifiers);
            }
            else if (Type == ClusterNodeType.Client)
            {
                var clientGameObject = new GameObject("ClientManager");
                Object.DontDestroyOnLoad(clientGameObject);
                Client = clientGameObject.AddComponent <ClientManager>();
                clientGameObject.AddComponent <MainThreadDispatcher>();
                Client.SetSettings(Settings);
                Client.StartConnection();
                Client.TryConnectToMaster();
            }
            Log.Info("Initialized the Simulation Network data.");
        }
Exemplo n.º 15
0
        // Appends to collectedAssets
        static void ExportToToolkit_Environment(
            Environment environment,
            string targetDirectory,
            HashSet <string> collectedAssets)
        {
            // make an environment
            var name     = environment.name;
            var settings = environment.m_RenderSettings;

            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);

            var prefab = AssetDatabase.LoadAssetAtPath <GameObject>(
                "Assets/Resources/" + settings.m_EnvironmentPrefab + ".prefab");

            PrefabUtility.InstantiatePrefab(prefab);

            RenderSettings.ambientSkyColor       = settings.m_AmbientColor;
            RenderSettings.fogColor              = settings.m_FogColor;
            RenderSettings.reflectionIntensity   = settings.m_ReflectionIntensity;
            RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Custom;

            RenderSettings.fog              = settings.m_FogEnabled;
            RenderSettings.fogMode          = settings.m_FogMode;
            RenderSettings.fogDensity       = settings.m_FogDensity;
            RenderSettings.fogStartDistance = settings.m_FogStartDistance;
            RenderSettings.fogEndDistance   = settings.m_FogEndDistance;

            // Lights
            Object.DestroyImmediate(Object.FindObjectOfType <Light>());
            for (int li = 0; li < environment.m_Lights.Count; li++)
            {
                var lsettings = environment.m_Lights[li];
                var light     = new GameObject("Light " + li, typeof(Light)).GetComponent <Light>();
                light.transform.position = lsettings.m_Position;
                light.transform.rotation = lsettings.m_Rotation;
                light.color     = lsettings.Color;
                light.type      = lsettings.m_Type;
                light.range     = lsettings.m_Range;
                light.spotAngle = lsettings.m_SpotAngle;
                light.intensity = 1.0f;
                light.shadows   = lsettings.m_ShadowsEnabled ? LightShadows.Hard : LightShadows.None;
            }

            // Camera
            var cam = Object.FindObjectOfType <Camera>();

            cam.transform.position = new Vector3(0, 15, 0);
            cam.nearClipPlane      = 0.5f;
            cam.farClipPlane       = 10000.0f;
            cam.fieldOfView        = 60;
            cam.clearFlags         = CameraClearFlags.Skybox;
            cam.backgroundColor    = settings.m_ClearColor;


            RenderSettings.customReflection = settings.m_ReflectionCubemap;
            if (settings.m_SkyboxCubemap)
            {
                Error("These guid shenanigans don't work yet: {0}", name);
                Material skyboxMaterialTmp  = new Material(Shader.Find("Custom/Skybox"));
                Guid     skyboxMaterialGuid = GuidUtils.Uuid5(environment.m_Guid, "skyboxMaterial");
                Material skyboxMaterial     = CreateAssetWithGuid_Incorrect(
                    skyboxMaterialTmp, name + "_Skybox.mat", skyboxMaterialGuid);
                string sbAssetPath = AssetDatabase.GetAssetPath(skyboxMaterial);

                collectedAssets.UnionWith(GetDependencies(sbAssetPath, includeRoot: false));

                string sbFinalPath = targetDirectory + "/" + sbAssetPath;
                CopyAsset(sbAssetPath, sbFinalPath);

                RenderSettings.skybox = skyboxMaterial;
                RenderSettings.skybox.SetColor("_Tint", settings.m_SkyboxTint);
                RenderSettings.skybox.SetFloat("_Exposure", settings.m_SkyboxExposure);
                RenderSettings.skybox.SetTexture("_Tex", settings.m_SkyboxCubemap);
            }
            else
            {
                RenderSettings.skybox = null;
            }

            Lightmapping.realtimeGI = false;
            Lightmapping.bakedGI    = false;

            // Store scene
            var sceneAssetPath = "Assets/Dynamic/" + name + ".unity";
            var sceneFinalPath = targetDirectory + "/Environments/" + Path.GetFileName(sceneAssetPath);

            EditorSceneManager.SaveScene(SceneManager.GetActiveScene(), sceneAssetPath);
            AssetDatabase.ImportAsset(sceneAssetPath, ImportAssetOptions.ForceSynchronousImport);

            CopyAsset(sceneAssetPath, sceneFinalPath);
            collectedAssets.UnionWith(GetDependencies(sceneAssetPath, includeRoot: false));
            SetFileGuid_Incorrect(sceneFinalPath, environment.m_Guid);

            AssetDatabase.DeleteAsset(sceneAssetPath);

            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
        }
Exemplo n.º 16
0
        public IEnumerator Setup()
        {
            var types = AppDomain.CurrentDomain.GetAssemblies()
                        .SelectMany(x => x.GetTypes())
                        .Where(t => typeof(BenchmarkUtils).IsAssignableFrom(t) && t.IsClass)
                        .OrderByDescending(x => ((BenchmarkUtilsImplPriorityAttribute)Attribute.GetCustomAttribute(x, typeof(BenchmarkUtilsImplPriorityAttribute))).Priority)
                        .ToList();

            m_BenchmarkTestsUtils = (BenchmarkUtils)Activator.CreateInstance(types.First());

            if (k_IsRunningUnderUtr)
            {
                m_ModelFolderPath = Directory.EnumerateDirectories(Directory.GetParent(Application.dataPath).Parent.FullName, ".PerformanceTestProjects", SearchOption.AllDirectories).FirstOrDefault();

                QualitySettings.SetQualityLevel(0);
                Screen.fullScreenMode      = FullScreenMode.FullScreenWindow;
                Screen.fullScreen          = true;
                QualitySettings.vSyncCount = 0;
            }
            else
            {
                m_ModelFolderPath = FindProjectsPath();
            }

            if (m_ModelFolderPath == null)
            {
                Debug.LogError("Unable to find Samples data. Reflect Samples require local Reflect Model data in '.PerformanceTestProjects' in " + Directory.GetParent(Application.dataPath).Parent.FullName);
            }

            if (!m_SceneLoaded)
            {
                //Load scene
                SceneManager.sceneLoaded += (s, a) => { m_SceneLoaded = true; };
                SceneManager.LoadScene(m_BenchmarkTestsUtils.GetScenePath(), LoadSceneMode.Single);

                yield return(new WaitWhile(() => m_SceneLoaded == false));

                m_BenchmarkTestsUtils.PostSceneSetup();

                //Too many exception with UI without user
                var uiStateManager = Object.FindObjectOfType <UIStateManager>();
                if (uiStateManager != null)
                {
                    uiStateManager.GetComponent <Canvas>().enabled = false;
                }

                var loginManager = Object.FindObjectOfType <LoginManager>();
                if (loginManager != null)
                {
                    loginManager.enabled = false;
                }

                yield return(null);

                //Activate Mars session to get the main camera
                var scene           = SceneManager.GetActiveScene();
                var rootGameObjects = new List <GameObject>();
                scene.GetRootGameObjects(rootGameObjects);
                foreach (var go in rootGameObjects)
                {
                    if (go.name.Equals("MARS Session"))
                    {
                        go.SetActive(true);
                        break;
                    }
                }

                m_ViewerReflectBootstrapper = UnityEngine.Object.FindObjectsOfType <ViewerReflectBootstrapper>().First();

                var actorSystemSetup = UnityEngine.Object.Instantiate(m_ViewerReflectBootstrapper.Asset);

                //Clear exclude and Migrate to get benchmark Actor
                actorSystemSetup.ExcludedAssemblies.RemoveAll(x => x == "BenchmarkAssembly");
                ActorSystemSetupAnalyzer.InitializeAnalyzer(actorSystemSetup);
                ActorSystemSetupAnalyzer.PrepareInPlace(actorSystemSetup);
                ActorSystemSetupAnalyzer.MigrateInPlace(actorSystemSetup);

                //Create and connect new actor
                var newProviderSetup = actorSystemSetup.CreateActorSetup <BenchmarkActor>();
                actorSystemSetup.ReplaceActor(actorSystemSetup.GetActorSetup <DataProviderActor>(), newProviderSetup);
                actorSystemSetup.ConnectNet <SpatialDataChanged>(actorSystemSetup.GetActorSetup <DynamicEntryFilterActor>(), newProviderSetup);

                //Assign root transform to GameObjectBuilderActor and SpatialActor
                actorSystemSetup.GetActorSetup <GameObjectBuilderActor>().GetActorSettings <GameObjectBuilderActor.Settings>().Root = GameObject.Find("Root").transform;
                actorSystemSetup.GetActorSetup <SpatialActor>().GetActorSettings <SpatialActor.Settings>().Root = GameObject.Find("Root").transform;

                //Replace Asset by modified temp asset
                m_ViewerReflectBootstrapper.Asset = actorSystemSetup;

                yield return(null);

                var freeFly = Camera.main.GetComponent <FreeFlyCamera>();
                if (freeFly != null)
                {
                    freeFly.enabled = false;
                }

                if (k_IsRunningUnderUtr)
                {
                    m_ViewerReflectBootstrapper.StartCoroutine(disableVsync());
                }

                yield return(new WaitForSeconds(10));
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Gets the random spawn point of the indicated role.
        /// </summary>
        /// <param name="roleType">RoleType</param>
        /// <returns>Vector3 spawnPoint</returns>
        public static Vector3 GetRandomSpawnPoint(RoleType roleType)
        {
            GameObject randomPosition = Object.FindObjectOfType <SpawnpointManager>().GetRandomPosition(roleType);

            return(randomPosition == null ? Vector3.zero : randomPosition.transform.position);
        }
Exemplo n.º 18
0
        public static void BuildStandalonePlayer()
        {
            var outputPath = $"{c_RelativeDirPrefix}{GetPlatformName()}_EXE";            //EditorUtility.SaveFolderPanel("Choose Location of the Built Game", "", "");

            if (outputPath.Length == 0)
            {
                return;
            }

            var levels = GetLevelsFromBuildSettings();

            if (levels.Length == 0)
            {
                Debug.Log("Nothing to build.");
                return;
            }

            #region 根据XAsset BuildInScene配置复原Unity的BuildInScene 因为我们为了支持在编辑器模式下的测试而必须将所有Scene放到Unity的BuildInSetting里

            var assets = new List <string>();
            var rules  = BuildScript.GetBuildRules();
            foreach (var asset in rules.scenesInBuild)
            {
                var path = AssetDatabase.GetAssetPath(asset);
                if (string.IsNullOrEmpty(path))
                {
                    continue;
                }
                assets.Add(path);
            }
            foreach (var rule in rules.rules)
            {
                if (rule.searchPattern.Contains("*.unity"))
                {
                    assets.AddRange(rule.GetAssets());
                }
            }
            var scenes = new EditorBuildSettingsScene[assets.Count];
            for (var index = 0; index < assets.Count; index++)
            {
                var asset = assets[index];
                scenes[index] = new EditorBuildSettingsScene(asset, true);
            }
            EditorBuildSettings.scenes = scenes;

            #endregion

            // 如果执行打包,就强行替换为非本地调试模式,进行AB加载与云端服务器连接
            Updater updater       = Object.FindObjectOfType <Updater>();
            bool    isDevelopMode = updater.DevelopmentMode;
            updater.DevelopmentMode = false;

            var targetName = GetBuildTargetName(EditorUserBuildSettings.activeBuildTarget);
            if (targetName == null)
            {
                return;
            }
#if UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0
            BuildOptions option = EditorUserBuildSettings.development ? BuildOptions.Development : BuildOptions.None;
            BuildPipeline.BuildPlayer(levels, path + targetName, EditorUserBuildSettings.activeBuildTarget, option);
#else
            var buildPlayerOptions = new BuildPlayerOptions {
                scenes                  = levels,
                locationPathName        = outputPath + targetName,
                assetBundleManifestPath = GetAssetBundleManifestFilePath(),
                target                  = EditorUserBuildSettings.activeBuildTarget,
                options                 = EditorUserBuildSettings.development ? BuildOptions.Development : BuildOptions.None
            };
            BuildPipeline.BuildPlayer(buildPlayerOptions);
#endif
            updater.DevelopmentMode = isDevelopMode;
        }
Exemplo n.º 19
0
 public static T FindObjectOfType <T>() where T : Object
 {
     return((T)((object)Object.FindObjectOfType(typeof(T))));
 }
        // the actual test
        public static IEnumerator TestScene(TestFrameworkTools.TestInfo testInfo)
        {
            var prjRelativeGraphsPath = TestFrameworkTools.s_Path.Aggregate(TestFrameworkTools.s_RootPath, Path.Combine);
            var filePath = Path.Combine(prjRelativeGraphsPath, testInfo.relativePath);

            // open the scene
            EditorSceneManager.OpenScene(filePath);

            SetupSceneForRenderPipelineTest testSetup = Object.FindObjectOfType <SetupSceneForRenderPipelineTest> ();

            Assert.IsNotNull(testSetup, "No SetupSceneForRenderPipelineTest in scene " + testInfo.name);
            Assert.IsNotNull(testSetup.cameraToUse, "No configured camera in <SetupSceneForRenderPipelineTest>");

            testSetup.Setup();

            for (int i = 0; i < testInfo.frameWait; ++i)
            {
                yield return(null);
            }

            while (UnityEditor.Lightmapping.isRunning)
            {
                yield return(null);
            }

            // Handle play mode and things to do before
            if (testSetup.testInPlayMode)
            {
                //if (!testSetup.invokeAtStart) testSetup.thingToDoBeforeTest.Invoke();
                //EditorApplication.isPlaying = true;
            }
            else
            {
                testSetup.thingToDoBeforeTest.Invoke();
            }

            // Render the camera
            Texture2D captured = TestFrameworkTools.RenderSetupToTexture(testSetup);

            // Load the template
            Texture2D fromDisk         = new Texture2D(2, 2);
            string    dumpFileLocation = "";

            if (!TestFrameworkTools.FindReferenceImage(testInfo, ref fromDisk, captured, ref dumpFileLocation))
            {
                Assert.Fail("Template file not found for {0}, creating it at {1}.", testInfo.name, dumpFileLocation);
            }

            // Compare
            var areEqual = TestFrameworkTools.CompareTextures(fromDisk, captured, testInfo.threshold);

            if (!areEqual)
            {
                var failedPath = Path.Combine(Directory.GetParent(Application.dataPath).ToString(), "SRP_Failed");
                Directory.CreateDirectory(failedPath);
                var misMatchLocationResult   = Path.Combine(failedPath, string.Format("{0}.{1}", testInfo.name, "png"));
                var misMatchLocationTemplate = Path.Combine(failedPath, string.Format("{0}.template.{1}", testInfo.name, "png"));
                var generated = captured.EncodeToPNG();
                File.WriteAllBytes(misMatchLocationResult, generated);
                File.Copy(dumpFileLocation, misMatchLocationTemplate);
            }

            Assert.IsTrue(areEqual, "Scene from {0}, did not match .template file.", testInfo.relativePath);

            testSetup.TearDown();
        }
Exemplo n.º 21
0
        public IEnumerator LoadMapFromPackageFileAsync(MapInfo mapInfo, Action <bool> isSuccess)
        {
            if (_isLoading)
            {
                yield break;
            }

            _isLoading = true;
            _lobbyName = "";

            UnloadMap();
            Logger.LogText("Loading map: " + mapInfo.FilePath + " -> " + mapInfo.PackageInfo.Descriptor.Name);

            var bundleDataStream = MapFileUtils.GetMapDataStreamFromZip(mapInfo);

            if (bundleDataStream == null)
            {
                Logger.LogText("Bundle not found in package");

                _isLoading = false;
                isSuccess(false);
                yield break;
            }

            var loadBundleRequest = AssetBundle.LoadFromStreamAsync(bundleDataStream);

            yield return(loadBundleRequest);

            var bundle = loadBundleRequest.assetBundle;

            if (bundle == null)
            {
                Logger.LogText("Bundle NOT LOADED");

                _isLoading = false;
                isSuccess(false);
                yield break;
            }

            Logger.LogText("Bundle loaded");

            var assetNames = bundle.GetAllAssetNames();

            Logger.LogText("Asset count: " + assetNames.Length + ", assets: " + string.Join(";", assetNames));

            Logger.LogText("Asset name: " + mapInfo.PackageInfo.Descriptor.Name);

            string[] scenePath = bundle.GetAllScenePaths();

            if (scenePath.Length <= 0)
            {
                Logger.LogText("Bundle NOT LOADED");

                _isLoading = false;
                isSuccess(false);
                yield break;
            }

            var scene = SceneManager.LoadSceneAsync(scenePath[0], LoadSceneMode.Additive);

            yield return(scene);

            GameObject[]  allObjects = Object.FindObjectsOfType <GameObject>();
            MapDescriptor descriptor = Object.FindObjectOfType <MapDescriptor>();

            foreach (GameObject gameObject in allObjects)
            {
                if (gameObject.scene.name != "GorillaTagNewVisuals" && gameObject.scene.name != "DontDestroyOnLoad")
                {
                    if (gameObject.transform.parent == null & gameObject.transform != descriptor.transform)
                    {
                        gameObject.transform.SetParent(descriptor.transform);
                    }
                }
            }
            GameObject map = descriptor.gameObject;

            if (map == null)
            {
                _isLoading = false;
                isSuccess(false);
                bundle.Unload(false);
                yield break;
            }

            Logger.LogText("Map asset loaded: " + map.name);
            _lobbyName = mapInfo.PackageInfo.Descriptor.Author + "_" + mapInfo.PackageInfo.Descriptor.Name;
            if (!String.IsNullOrWhiteSpace(mapInfo.PackageInfo.Config.GUID))
            {
                _lobbyName = mapInfo.PackageInfo.Config.GUID + "_" + mapInfo.PackageInfo.Config.Version;
            }

            Exception ex = null;

            yield return(ProcessAndInstantiateMap(map).AsIEnumerator(exception => ex = exception));

            yield return(null);

            if (ex != null)
            {
                Logger.LogException(ex);

                isSuccess(false);
                _isLoading = false;
                bundle.Unload(false);
                yield break;
            }

            bundle.Unload(false);
            bundleDataStream.Close();

            _isLoading = false;
            isSuccess(true);
        }
Exemplo n.º 22
0
 private void UpdateCoinText()
 {
     Object.FindObjectOfType <StoreController>().SetCoinsBasedOnGameData();
 }
Exemplo n.º 23
0
        public override void OnActivated()
        {
            if (Object.FindObjectOfType <WaveVR_Init>() == null)
            {
                VRModule.Instance.gameObject.AddComponent <WaveVR_Init>();
            }

#if !UNITY_EDITOR && VIU_WAVEVR_3_0_0_OR_NEWER
            if (Object.FindObjectOfType <WaveVR_ButtonList>() == null)
            {
                VRModule.Instance.gameObject.AddComponent <WaveVR_ButtonList>();
            }
#endif

#if VIU_WAVEVR_3_0_0_OR_NEWER
            var digitalCapability = (uint)WVR_InputType.WVR_InputType_Button;
            var analogCapability  = (uint)(WVR_InputType.WVR_InputType_Button | WVR_InputType.WVR_InputType_Touch | WVR_InputType.WVR_InputType_Analog);
            var inputRequests     = new WVR_InputAttribute_t[]
            {
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Menu, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Grip, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_DPad_Left, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_DPad_Up, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_DPad_Right, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_DPad_Down, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Volume_Up, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Volume_Down, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Enter, axis_type = WVR_AnalogType.WVR_AnalogType_None, capability = digitalCapability
                },

                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Touchpad, axis_type = WVR_AnalogType.WVR_AnalogType_2D, capability = analogCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Thumbstick, axis_type = WVR_AnalogType.WVR_AnalogType_2D, capability = analogCapability
                },

                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Digital_Trigger, axis_type = WVR_AnalogType.WVR_AnalogType_1D, capability = analogCapability
                },
                new WVR_InputAttribute_t()
                {
                    id = WVR_InputId.WVR_InputId_Alias1_Trigger, axis_type = WVR_AnalogType.WVR_AnalogType_1D, capability = analogCapability
                },
            };

#if !UNITY_EDITOR
            Interop.WVR_SetInputRequest(WVR_DeviceType.WVR_DeviceType_Controller_Right, inputRequests, (uint)inputRequests.Length);
            Interop.WVR_SetInputRequest(WVR_DeviceType.WVR_DeviceType_Controller_Left, inputRequests, (uint)inputRequests.Length);
#endif
#endif

            EnsureDeviceStateLength(DEVICE_COUNT);

            UpdateTrackingSpaceType();

            s_moduleInstance = this;

            WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.NEW_POSES, OnNewPoses);
        }
Exemplo n.º 24
0
 static Pathfinder()
 {
     Player = Object.FindObjectOfType <Player>();
 }
Exemplo n.º 25
0
        public static async void CopyAssetBundlesTo(string path)
        {
            var prefix = $"JEngine.Editor.Setting.{Application.productName}";
            var jump   = PlayerPrefs.GetString($"{prefix}.JumpStartUpScene", "1") == "1";
            var scene  = SceneManager.GetActiveScene();

            if (scene.path != Setting.StartUpScenePath)
            {
                if (!jump)
                {
                    Debug.LogError("请前往启动场景进行该操作,或在JEngine面板配置启动场景");
                    return;
                }

                string name = Setting.StartUpScenePath;

                scene = EditorSceneManager.OpenScene(name, OpenSceneMode.Additive);
                while (!scene.isLoaded)
                {
                    await Task.Delay(10);
                }
            }

            bool vfs = Object.FindObjectOfType <Updater>().enableVFS;

            EditorSceneManager.CloseScene(scene, true);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            var versions = new List <VFile>();

            if (!vfs)
            {
                versions.AddRange(Versions.LoadVersions(outputPath + "/" + Versions.Filename));
                versions.Add(new VFile()
                {
                    name = Versions.Filename
                });
                versions.RemoveAt(versions.FindIndex(file => file.name.Equals(Versions.Dataname)));
            }
            else
            {
                versions.Add(new VFile()
                {
                    name = Versions.Filename
                });
                versions.Add(new VFile()
                {
                    name = Versions.Dataname
                });
            }

            foreach (var item in versions)
            {
                var src  = outputPath + "/" + item.name;
                var dest = path + "/" + item.name;
                if (File.Exists(src))
                {
                    File.Copy(src, dest, true);
                }
            }

            AssetDatabase.Refresh();
        }
Exemplo n.º 26
0
 public void WithUnityComponentUniqueInstance <T>() where T : Component, TInterfaceType
 {
     UniqueInstanceServices[typeof(TInterfaceType)] = Object.FindObjectOfType <T>();
 }
Exemplo n.º 27
0
        internal static void FilenameHook(ref string path, ref bool useDefaultData)
        {
            var sex = path == "chara/female/" ? 1 : 0;

            useDefaultData = useDefaultData && KK_BrowserFolders.ShowDefaultCharas.Value;

            var freeh = Object.FindObjectOfType <FreeHPreviewCharaList>();

            if (freeh != null)
            {
                FreeHFolders.Init(freeh, sex);

                var overridePath = FreeHFolders.CurrentRelativeFolder;
                if (!string.IsNullOrEmpty(overridePath))
                {
                    path = overridePath;
                }

                return;
            }

            var newGame = Object.FindObjectOfType <EntryPlayer>();

            if (newGame != null)
            {
                NewGameFolders.Init(newGame, sex);

                var overridePath = NewGameFolders.CurrentRelativeFolder;
                if (!string.IsNullOrEmpty(overridePath))
                {
                    path = overridePath;
                }

                return;
            }

            var classroom = Object.FindObjectOfType <PreviewCharaList>();

            if (classroom != null)
            {
                ClassroomFolders.Init(classroom, sex);

                var overridePath = ClassroomFolders.CurrentRelativeFolder;
                if (!string.IsNullOrEmpty(overridePath))
                {
                    path = overridePath;
                }

                return;
            }

            // Prevents breaking the kkp coordinate list in maker
            var isCoord = path.TrimEnd('\\', '/').EndsWith("coordinate", StringComparison.OrdinalIgnoreCase);

            if (!isCoord)
            {
                var maker = Object.FindObjectOfType <CustomCharaFile>();
                if (maker != null)
                {
                    var overridePath = MakerFolders.CurrentRelativeFolder;
                    if (!string.IsNullOrEmpty(overridePath))
                    {
                        path = overridePath;
                    }
                }
            }
            else
            {
                var makerOutfit = Object.FindObjectOfType <CustomCoordinateFile>();
                if (makerOutfit != null)
                {
                    var overridePath = MakerOutfitFolders.CurrentRelativeFolder;
                    if (!string.IsNullOrEmpty(overridePath))
                    {
                        path = overridePath;
                    }
                }
            }
        }
Exemplo n.º 28
0
        public void SaveToFile(string path)
        {
            var ms         = new MemoryStream();
            int headersize = 0;


            //-------------Write data of file header------------------
            {
                var header = new FileHeader();
                var count  = objects.Count + framesData.Count;
                header.DataCount = count;
                var data = header.getBytes();
                ms.Write(data, 0, data.Length);
                headersize = data.Length + header.DataCount * (int)DataObjectBase.DataObjectHeaderSize;
            }
            //--------------------------------------------------------
            var dataMS = new MemoryStream();

            //-------------Write data of resources------------------
            string outputDir = (new FileInfo(path)).DirectoryName;
            //string datasetfile = outputDir + "/dataset.txt";
            string datasetfile = path + ".fix";
            var    dataset     = new StreamWriter(datasetfile);

            {
                foreach (var keydata in objects)
                {
                    var obj = keydata.Value;
                    obj.WriteToStream(dataMS);
                    obj.WriteHeaderData(ms);

                    //-------for copy texture file----------

                    var tex    = obj as TextureObject;
                    var config = Object.FindObjectOfType <SceneConfig>();
                    if (tex != null && config.isExternalTexture)
                    {
                        //
                        //
                        //Debug.Log("cccc:");
                        if (tex.externalTextureData != null)
                        {
                            var texData = tex.externalTextureData;
                            var tex2d   = tex._texture as Texture2D;
                            if (tex2d != null)
                            {
                                //
                                // FileInfo dstinfo = new FileInfo(path);
                                // FileInfo srcinfo = new FileInfo(tex.externalTextureData.path);
                                string ext  = ".jpg";
                                byte[] data = null;

                                if (tex2d.format == TextureFormat.RGBA32)
                                {
                                    ext  = ".png";
                                    data = ImageConversion.EncodeToPNG(tex2d);
                                }
                                else if (tex2d.format == TextureFormat.ETC2_RGBA8)
                                {
                                    ext = ".pkm";
                                    var rawDatax = tex2d.GetRawTextureData();
                                    data     = new byte[rawDatax.Length + 16];
                                    data[0]  = (byte)'P';
                                    data[1]  = (byte)'K';
                                    data[2]  = (byte)'M';
                                    data[3]  = (byte)' ';
                                    data[4]  = (byte)'2';
                                    data[5]  = (byte)'0';
                                    data[6]  = (byte)((3 >> 8) & 0xFF);
                                    data[7]  = (byte)((3 >> 0) & 0xFF);
                                    data[8]  = (byte)((tex2d.width >> 8) & 0xFF);
                                    data[9]  = (byte)((tex2d.width >> 0) & 0xFF);
                                    data[10] = (byte)((tex2d.height >> 8) & 0xFF);
                                    data[11] = (byte)((tex2d.height >> 0) & 0xFF);
                                    data[12] = (byte)((tex2d.width >> 8) & 0xFF);
                                    data[13] = (byte)((tex2d.width >> 0) & 0xFF);
                                    data[14] = (byte)((tex2d.height >> 8) & 0xFF);
                                    data[15] = (byte)((tex2d.height >> 0) & 0xFF);

                                    Buffer.BlockCopy(rawDatax, 0, data, 16, rawDatax.Length);
                                }
                                else
                                {
                                    data = ImageConversion.EncodeToJPG(tex2d, config.jpegCompressQuality);
                                }

                                string filename = obj.ObjectID.ToString() + ext;
                                string outfile  = string.Format("{0}/{1}", outputDir, filename);
                                File.WriteAllBytes(outfile, data);


                                dataset.WriteLine(string.Format("{0} {1} {2} {3}",
                                                                filename,
                                                                texData.position + headersize + obj.Position,
                                                                texData.size,
                                                                texData.format));
                            }
                        }
                    }
                    //---------------------------------------
                }
            }
            dataset.Close();

            //--------------------------------------------------------

            //-------------Frames data of resources------------------
            {
                foreach (var obj in framesData)
                {
                    obj.WriteToStream(dataMS);
                    obj.WriteHeaderData(ms);
                }
            }
            //--------------------------------------------------------

            //-------------Flush the data to file------------------
            var resData = dataMS.ToArray();

            ms.Write(resData, 0, resData.Length);

            var info = new FileInfo(path);

            if (info.Exists)
            {
                info.Delete();
            }

            File.WriteAllBytes(path, ms.ToArray());
            //Debug.Log("count:" + objects.Count);
            //Debug.Log(message: "frames:" + framesData.Count);

            //testExportFile(path);

            RelayoutFile(path);
        }
        public new void SetUp()
        {
            var cam = Object.FindObjectOfType <Camera>();

            camParams.ToCamera(cam);
        }
Exemplo n.º 30
0
        public IEnumerator TestScene([ValueSource(typeof(CollectScenes), "scenes")] TestInfo testInfo)
        {
            var prjRelativeGraphsPath = s_Path.Aggregate("Assets", Path.Combine);
            var filePath = Path.Combine(prjRelativeGraphsPath, testInfo.relativePath);

            // open the scene
            EditorSceneManager.OpenScene(filePath);

            var testSetup = Object.FindObjectOfType <SetupSceneForRenderPipelineTest> ();

            Assert.IsNotNull(testSetup, "No SetupSceneForRenderPipelineTest in scene " + testInfo.name);
            Assert.IsNotNull(testSetup.cameraToUse, "No configured camera in <SetupSceneForRenderPipelineTest>");

            testSetup.Setup();

            for (int i = 0; i < testInfo.frameWait; ++i)
            {
                yield return(null);
            }

            while (UnityEditor.Lightmapping.isRunning)
            {
                yield return(null);
            }

            var rtDesc = new RenderTextureDescriptor(
                testSetup.width,
                testSetup.height,
                testSetup.hdr ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32,
                24);

            rtDesc.sRGB = PlayerSettings.colorSpace == ColorSpace.Linear;

            // render the scene
            var tempTarget = RenderTexture.GetTemporary(rtDesc);
            var oldTarget  = testSetup.cameraToUse.targetTexture;

            testSetup.cameraToUse.targetTexture = tempTarget;
            testSetup.cameraToUse.Render();
            testSetup.cameraToUse.targetTexture = oldTarget;

            // Readback the rendered texture
            var oldActive = RenderTexture.active;

            RenderTexture.active = tempTarget;
            var captured = new Texture2D(tempTarget.width, tempTarget.height, TextureFormat.ARGB32, false);

            captured.ReadPixels(new Rect(0, 0, testSetup.width, testSetup.height), 0, 0);
            RenderTexture.active = oldActive;

            var rootPath     = Directory.GetParent(Application.dataPath).ToString();
            var templatePath = Path.Combine(rootPath.ToString(), "ImageTemplates");

            // find the reference image
            var dumpFileLocation = Path.Combine(templatePath, string.Format("{0}.{1}", testInfo.relativePath, "png"));

            if (!File.Exists(dumpFileLocation))
            {
                // no reference exists, create it
                var fileInfo = new FileInfo(dumpFileLocation);
                fileInfo.Directory.Create();

                var generated = captured.EncodeToPNG();
                File.WriteAllBytes(dumpFileLocation, generated);
                Assert.Fail("Template file not found for {0}, creating it at {1}.", testInfo.name, dumpFileLocation);
            }

            var template = File.ReadAllBytes(dumpFileLocation);
            var fromDisk = new Texture2D(2, 2);

            fromDisk.LoadImage(template, false);

            var areEqual = CompareTextures(fromDisk, captured, testInfo.threshold);

            if (!areEqual)
            {
                var failedPath = Path.Combine(rootPath.ToString(), "Failed");
                Directory.CreateDirectory(failedPath);
                var misMatchLocationResult   = Path.Combine(failedPath, string.Format("{0}.{1}", testInfo.name, "png"));
                var misMatchLocationTemplate = Path.Combine(failedPath, string.Format("{0}.template.{1}", testInfo.name, "png"));
                var generated = captured.EncodeToPNG();
                File.WriteAllBytes(misMatchLocationResult, generated);
                File.WriteAllBytes(misMatchLocationTemplate, template);
            }

            Assert.IsTrue(areEqual, "Scene from {0}, did not match .template file.", testInfo.relativePath);
        }