示例#1
0
        public override void Initialize(FObjectInitializer initializer)
        {
            base.Initialize(initializer);

            if (baseMaterial.Value == null)
            {
                baseMaterial.Value = ConstructorHelpers.FObjectFinder <UMaterialInterface> .Find("Material'/Game/Puzzle/Meshes/BaseMaterial.BaseMaterial'");
            }
            if (blueMaterial.Value == null)
            {
                blueMaterial.Value = ConstructorHelpers.FObjectFinder <UMaterialInterface> .Find("MaterialInstanceConstant'/Game/Puzzle/Meshes/BlueMaterial.BlueMaterial'");
            }
            if (orangeMaterial.Value == null)
            {
                orangeMaterial.Value = ConstructorHelpers.FObjectFinder <UMaterialInterface> .Find("MaterialInstanceConstant'/Game/Puzzle/Meshes/OrangeMaterial.OrangeMaterial'");
            }

            UStaticMesh mesh = ConstructorHelpers.FObjectFinder <UStaticMesh> .Find("StaticMesh'/Game/Puzzle/Meshes/PuzzleCube.PuzzleCube'");

            if (mesh != null)
            {
                BlockMesh = initializer.CreateDefaultSubobject <UStaticMeshComponent>(this, new FName("BlockMesh"));
                BlockMesh.SetStaticMesh(mesh);
                BlockMesh.RelativeLocation = new FVector(0, 0, 25);
                BlockMesh.RelativeScale3D  = new FVector(1, 1, 0.25f);
                RootComponent = BlockMesh;

                if (blueMaterial.Value != null)
                {
                    BlockMesh.SetMaterial(0, blueMaterial.Value);
                }
            }
        }