How to create a unity project using a custom piece of code - unity3d

What I want to do is basically press a button in my application(C# WPF) and create a unity project in a predefined version, import some packages and then launch it.
I have no Idea if that's possible or not. I haven't found anything yet.
Would be awesome if you got a way to do it! Thanks in advance :)

You can use the Unity command line to create a project and import a package in c# like this:
using System.Diagnostics;
...
var arguments = $" -createProject {path} -importPackage {packagePath}";
var process = Process.Start(#"C:\Program Files\Unity\Editor\Unity.exe", arguments);
Check this page https://docs.unity3d.com/Manual/EditorCommandLineArguments.html

Related

Xcode Ignoring import

I have just installed Xcode 11 and when I try to create new fresh project with the SwiftUI check mark selected it returns an error.
Not able to build and run successfully.
File 'ContentView.swift' is part of module 'SwiftUI'; ignoring import
ContentView.swift
Use of undeclared type 'View'
SceneDelegate.swift
Use of unresolved identifier 'UIHostingController'
I have tried removing all derived data and also set command-line tools to 11
Your project is named SwiftUI - please try using a different name.
Detailed Answer
Each project you create has a module with the same name as the project. So there are two SwifUI modules here:
The actual SwiftUI
The project itself
Xcode always takes the nearest definition as the default. So your SwiftUI is closer than the system's SwiftUI. But you are in the project's module already! So Xcode ignores the import.
A very common mistake is to name the project same as one of the using frameworks! (e.g. CoreData, SwiftUI, SceneKit, Metal)
Solution
As Matteo mentioned in his answer, Don't name your project same with another module. Change it to anything else.
Note that It could appear as an error too. For example, if you name your project CoreData and using SwiftUI, the error appears as Circular dependency error:
Circular dependency between modules 'CoreData' and 'SwiftUI'
Because Xcode gets confused about modules and can not detect what the real issue is.
How can we access our module's classes instead of the system's module?
Imagine you have a class named Section in a custom framework called MyProject and you imported it alongside the SwiftUI.
import SwiftUI
import MyProject
Section // <- This could be either SwiftUI's section or MyProject's Section
To make it clear for the compiler (and anyone else), you should call the module before the class name:
SwiftUI.Section // <- This returns the SwiftUI's Section
MyProject.Section // <- This returns the MyProject's Section
Try with different project name. With SwiftUI, it will always show compilation error. Just change the name and enjoy coding with SwiftUI

No such module purelayout in swift with manual installation?

I have been at this for over an hour. I am desperate.
I am trying to implement this here https://github.com/enisgayretli/EGFloatingTextField and this is my previous question Best way to achieve UILabel animation effect in Swift?
For the text field to work I need to import Purelayout. I'm working in swift and this is where things don't work- I've tried all the methods on the purelayout github but can't for the life of me import purelayout.
No matter what I do I get no such module purelayout. I am trying to do the manual installation and I have 1. Dragged and copied the purelayout source files into my project 2. Written the import Purelayout.h line in my bridging header
Where am I going wrong here? Am I configuring my header wrong? When I drag the files in it wants to configure a new Bridger and creates a blank file.. Could this be the problem?
My project will not compile. I can't understand this.

Unity - Deprecated EditorApplication

I just have updated my Unity to 5.3.1 and it seems like EditorApplication class is already deprecated. The Unity suggests me to use instead the EditorSceneManager.OpenScene but looks like it's not returning of type bool anymore. Therefore causing my game to stop compiling.
Any help about this?
Thanks!
Usually due to deprecated code unity itself offers some changes in your code you can make a backup and try that if unity informs you of it ,but if you want to know if it has been loaded or not you can use its return value which is a struct of type Scene.
SceneManagement.Scene newScene = EditorSceneManager.OpenScene("myScene");
if(newScene.isLoaded) {
//do something
}
There is another method also named IsVaild You Can try that too.
further doc :
http://docs.unity3d.com/ScriptReference/SceneManagement.Scene.html
It's hard to help you without any information on what you actually want to do... This link may help though, it's about upgrading to Unity 5.3.

How to save annotation in flexpaper?

I m trying to save annotation in flexpaper.. I tried using this
marksArray = JSON.stringify($FlexPaper('documentViewer').getMarkList());
var initialMarks = JSON.parse(marksArray);
$FlexPaper('documentViewer').addMarks(initialMarks);
but it's not working..
In console, I tried using marks = $FlexPaper('documentViewer').getMarkList()[0];
I can see that its storing inside marks but for $FlexPaper('documentViewer').addMarks(marks) it's showing undefined.
Am I missing something? Please help me, Thanks in advance.
We 'll get the require files after downloading Annotations Web Server Package from flexpaper classic page. what I missed was <'flexpaper:annotations_handler runat="server"/> It should be inside the script in simple_document.aspx page. And In annotations_handlers.ascx page I shifted that (onMarkCreated ,onMarkDeleted,onMarkChanged) JQuery code to flexpaper_handlers.js file. After these changes its working for me.

Need to re-add GoogleMobileAds on each build?

Whenever I build my game for iOS, I need to remove GoogleMobileAds.framework and add it again with Add Files To ..., otherwise XCode complains that "module 'GoogleMobileAds' not found."
Does anyone have any idea how to get it to 'stick'? (I'm pretty new with XCode)
You can add the framework automatically to the Xcode project after Unity generates it using the [PostBuildProcess] attribute in an Editor script. Place the script in Assets/Editor.
Here's an example for adding frameworks. Here's a plugin that seems to do the heavy lifting for you using a JSON file to specify the modifications.
[PostProcessBuild] // <- this is where the magic happens
public static void OnPostProcessBuild(BuildTarget target, string path) {
// Do post-build processing here
}