Пример #1
0
        private void DuplicateComponentMemoryManagementTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            try {
                Actor          actor              = new Actor();
                SceneComponent sceneComponent     = new SceneComponent(actor, setAsRoot: true);
                SceneComponent duplicateReference = actor.GetRootComponent <SceneComponent>();

                if (!sceneComponent.Equals(duplicateReference))
                {
                    Debug.Log(LogLevel.Error, "Scene component reference equality check failed!");

                    return;
                }

                sceneComponent.Destroy();

                Debug.Log(LogLevel.Display, "Triggering invalid actions after the destruction");

                duplicateReference.AddLocalOffset(default(Vector3));
                duplicateReference.Destroy();
            }

            catch (Exception exception) {
                Debug.Log(LogLevel.Display, "The exception has successfully reached: " + exception.Message);

                return;
            }

            Debug.Log(LogLevel.Error, "Test failed!");
        }
Пример #2
0
        public void OnBeginPlay()
        {
            World.GetFirstPlayerController().SetViewTarget(World.GetActor <Camera>("MainCamera"));

            instancedStaticMeshComponent.SetStaticMesh(StaticMesh.Cube);
            instancedStaticMeshComponent.SetMaterial(0, material);
            instancedStaticMeshComponent.CreateAndSetMaterialInstanceDynamic(0).SetVectorParameterValue("Color", LinearColor.White);

            for (int i = 0; i < maxCubes; i++)
            {
                sceneComponent.SetRelativeLocation(new Vector3(150.0f * i, 50.0f * i, 100.0f * i));
                sceneComponent.SetRelativeRotation(Maths.CreateFromYawPitchRoll(5.0f * i, 0.0f, 0.0f));
                sceneComponent.AddLocalOffset(new Vector3(15.0f * i, 20.0f * i, 25.0f * i));
                sceneComponent.GetTransform(ref transforms[i]);
                instancedStaticMeshComponent.AddInstance(transforms[i]);
            }

            Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, "Instances are created! Number of instances: " + instancedStaticMeshComponent.InstanceCount);
        }
Пример #3
0
        private void ComponentMemoryManagementTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            try {
                Actor          actor          = new Actor();
                SceneComponent sceneComponent = new SceneComponent(actor, setAsRoot: true);

                sceneComponent.Destroy();

                Debug.Log(LogLevel.Display, "Triggering invalid action after the destruction");

                sceneComponent.AddLocalOffset(default(Vector3));
            }

            catch (Exception exception) {
                Debug.Log(LogLevel.Display, "The exception has successfully reached: " + exception.Message);

                return;
            }

            Debug.Log(LogLevel.Error, "Test failed!");
        }