Post

Replies

Boosts

Views

Activity

Strange issues with VisionOS template
Hello, I'm getting some strange behavior as I keep working with AVP on Xcode. First the basic template used to be normal, and when I previewed contentView it would display the basic sphere (using volume preset) right in the center of the screen. Now, when I create any basic template, the preview window is way elevated upwards to where its basically going thru the ceiling in the room. For the life of me I cannot get Xcode to correct this behavior. Also, while I can create a scene with assets in RealityKit, and try to view it in my content bundle following this Apple tutorial https://developer.apple.com/videos/play/wwdc2023/10203/ I cannot get my new scene to show in an immersive view file. I made sure to use the swiftUI template for the immersive view and I had the correct setup for it. My naming conventions are correct and there are no typos or errors (that I know of). I CAN get the basic template scene to show up, but not my custom scene with a pancake model in it. I've gone thru the video several times, but that still doesn't solve the above issue of the initial template previewing way to high. Does anyone have any advice on fixes for this subject? Edit : I may have located the issue to importing assets and using them in a new scene in realityComposerPro. Still not sure why it breaks after creating a scene in RCP. I haven't even used them in y project yet. (Started a new one) --> If I reset the project it removes the errors. But I still can't see my pancake, even if I just replace the template scene with a basic scene with just the asset in it. Much like the sphere but pancake instead. Also the initial scene may be high because using the volume template the view starts at the users feet. That might be why
0
1
329
Jan ’24
Best Practices for state flow in swiftUI?
I'm creating a basic app that needs state variables to be used in multiple parts. It's a multiplication practice app. I intend to gamify it a bit but for now, I'm setting up the basics. My initial thought is to set up an Observer Pattern for state management, but I'm having trouble doing that in swiftUI. I have a Number Pad component that holds a number pad I created as well as the state variable for the user's answer. I have a number Window component that holds 2 numbers from the game logic. Finding the product of these numbers is supposed to increment the score and change the numbers. My content view contains the 2 components and a box that displays the current number entered by the user. They are all inside one Vstack. I also import my game logic class as a stateObject in the content view The layout looks alright. I can get 2 random numbers to show up on start of the app. I also have the user input from the number pad displaying in a box in the content view. But getting the userInput to match the game logics expected answer is where I'm running into trouble. And when I change something everything else breaks. I'm pretty sure it's my state management. I've done some reading about Observable Object, state, binding, published and stateobject imports. So I'm semi-familiar with them, just not how to use them effectively. How would you approach getting your game logic state variables (leftNum, rightNum, and Answer) to display to the number window? While also waiting for the user input to match the Answer variable and run some methods? What components would you have extending Observable object vs just using state or binding? Thanks for your time Below is a visual of my app preview
0
1
793
Apr ’23
App Builds fine, but will not do anything or preview
I originally started out in playgrounds. Some background I'm new to Swift but not programming in general. Anyways in both playgrounds and Xcode, my app stopped previewing. I can build the app just fine.. but nothing happens and appears. I get no errors other than the app took too long to load. Here are the diagnostics from Xcode ---> PreviewUpdateTimedOutError: Updating took more than 5 seconds Updating a preview from in MathMaddness.app (41055) took more than 5 seconds. I just had a lengthy battle with getting State working. Including observable objects, stateObjects etc. I finally fixed everything and now nothing will preview anymore. Thanks for the help UPDATE: Infinite loop that updated state that updated the state of swiftui.
5
0
1.4k
Apr ’23