Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Folcon
@Folcon
Just a quick question, what is the state of godot interop right now? Is it possible to build cross platform output? I'm thinking of putting together a new prototype and I'm currently leaning on using unity arcadia, though at the moment I have more familiarity with godot (used it in a gamejam to make a game =)...). Thoughts?
I'd like to stick the result on itch.io, so it being cross platform would be preferable =)... I believe unity can output valid win / linux / mac output?
saikyun
@saikyun
no clue about godot, I think you'd "just" have to try. but maybe someone else knows :)
wrt arcadia -- I've successfully ran it on windows and mac, and it's supposed to work on linux as well, just haven't tried it myself :)
Blue
@tinkerttoy
I can confirm that Arcadia Unity runs on Linux, cuz I'm making a game with it on Linux right now
Folcon
@Folcon
Ok, I might skip godot for now then, though I do like the idea of giving it a fair shake again in the future =)...
Thanks!
Folcon
@Folcon
Are there any helpers / info around creating attributes accessible in the editor? Stuff like having numbers / sliders be displayed etc.
Folcon
@Folcon
I'm currently going through this[0] tutorial with the aim of writing 0 C#, not sure if it's possible, but I've been able to get bits working as I go. Would it be useful to publish it as a repo?
Paul M. Christian
@meta-meta
That's an awesome idea! Hmm AFAIK, editor fields come from public members on a Monobehavior so I would think you'd need something like gen-class or a namespace with :gen-class. Not sure if you need to AOT compile. https://clojure.org/reference/compilation
saikyun
@saikyun
@Folcon I tried doing some unity ui stuff some time ago. iirc I found it slow, but I tried doing 100s of fields, so might work ok with just a single game object:
https://github.com/saikyun/miracle.window
this would add a file menu item under Window. not sure if similar things could be used to show GUI stuff in the inspector
Folcon
@Folcon
I'm trying different things to see how it goes =)... I'll update as I know more...
Joseph Parker
@selfsame
oh before I forget, I have a new ArcadiaGodot game out at https://selfsame.itch.io/upworm
project files are there too (a bit too big for git with all the assets)
9 replies
Folcon
@Folcon
Oh nice!
Folcon
@Folcon

An update on my side, this is surprisingly fiddly... I think I've narrowed it down to these:
https://github.com/clojure/clojure-clr/wiki/Defining-types
https://github.com/clojure/clojure-clr/wiki/How-to-add-attributes

The Unity attribute for Range is: https://docs.unity3d.com/ScriptReference/RangeAttribute.html

which is possible to instantiate, but I suspect I need to call something like:

(defn ^{RangeAttribute #{10 500}} foo
  [arg]
  ...)

Not sure how it works when it has more than one arg, thought the docs here (https://github.com/clojure/clojure-clr/blob/886631fc104c31683eff977b9c7b48d9165cdd84/Clojure/Clojure.Source/clojure/core_clr.clj#L241) seem to imply it's some mix of sets and maps...

Still not quite sure how to do a field, I've been fiddling about with gen-class, but it keeps returning nil...

(gen-class
  :name Flock
  :extends UnityEngine.MonoBehaviour)
=> nil

I've had a bit more luck with defrecord / deftype, but not sure how to extend a class with it, MonoBehaviour isn't an interface after all...

I don't know the clr runtime that well, so it's slow going...

I'm going to get some sleep, I'll see how I feel later on the week, I might throw my hands up at this part and just turn them into prefabs, but it would be awesome to just programatically build this. If anyone has any ideas I'm all ears!

I've reproduced the c# I'm trying to replicate below, just knowing how to do this would make things a lot easier! So if there's anyone who knows the clr, please chime in! =)...

public class Flock : MonoBehaviour  {
  [Range(10, 500)]
  public int startingCount = 250;

}
Joseph Parker
@selfsame
@Folcon IIRC at some point Arcadia had inspector widgets for different types in it's state component, might be interesting to look through the commit history
Folcon
@Folcon

Hmm, some new and interesting breakage:

Loading Assets/Arcadia/Source/arcadia/linear.clj... 
System.InvalidOperationException: No such var: clojure.core/inline-arity-pred
  clojure.lang.Compiler.ResolveIn (clojure.lang.Namespace, clojure.lang.Symbol, System.Boolean)
  clojure.lang.Compiler.Resolve (clojure.lang.Symbol)
  clojure.lang.Compiler.AnalyzeSymbol (clojure.lang.Symbol)
  clojure.lang.Compiler.Analyze (clojure.lang.CljCompiler.Ast.ParserContext, object, System.String)

Not sure why it's suddenly started blowing up at this point, anyone seen this before?

Folcon
@Folcon
Some investigating seems to imply that vars are being looked up against clojure.core instead of the namespace they're located in...
Folcon
@Folcon
It's ignoring the quote operator as well, fully qualifying the name seems to work...
Folcon
@Folcon
And now it's magically working again >_<...
Folcon
@Folcon

Ok, so I sort of dumbly stumbled into this one =)...

(defn vec->c#list [v]
  (let [xs (|System.Collections.Generic.List`1[System.String]|.)]
    (doseq [e v]
      (.Add xs e))
    xs))

Anyone have anything more elegant that I missed? I specifically need a List of Strings, not Persistent List... Unity's new UI Toolkit doesn't like it if you try and bind Persistent Lists to dropdown boxes =)... If not I'll add it as a pattern!

Joseph Parker
@selfsame
@Folcon yeah that's probably the best way to do it
Folcon
@Folcon
Ok, will add something tomorrow =)
Folcon
@Folcon
Hmm, ok, I'm currently testing exporting and I'm getting a few errors around missing gameobjects, my clojure code creates the gameobjects dynamically. So they don't exist in the scene until the code runs, this works fine in the repl, but could it be a problem when exporting?
Folcon
@Folcon
Alternatively if anyone has suggestions how to call BuildPipeline.PrepareExport(); in Rider (or equivalent) I can try and step / debug it =)...
saikyun
@saikyun
@Folcon do you depend on those objects existing when the game starts? I often create an init-function which creates all the dynamic stuff before I run any update-functions
Folcon
@Folcon
I'm actually creating them using defonce's at the moment. So once the namespace loads they should be created, which is what's weird, it's almost like during export some of the functions are getting invoked, but not others? Or require's aren't firing? Really not sure.
Is there some kind of init script that people use to setup and build all their main gameobjects that I've completely missed?
I think the namespaces are AOT-compiled, so the objects are probably created during compile time :'D
I think I had some trouble like this, but it was a long time ago
Folcon
@Folcon
Does that approach still work if you do it across namespaces?
Folcon
@Folcon
Ok, nevermind, I didn't realise that I should hook+ my init script to Main Camera :start, that properly ensures things run correctly
I'll update my example project to reflect this!
Thanks @saikyun =)
Hmm, new error, which is good, so I can't create primitive's during Serialization, I'll have to adjust logic
Folcon
@Folcon
Ok managed to get a minimal example built and exported, so I updated the example project with that info =)... Will now need to see if this works if I pull in the rest of my changes. If anyone wants to give the example project a tire kick, it's here:
https://github.com/Folcon/arcadia-example-project/
Folcon
@Folcon
Ok, another learning, got to use setup functions to declare any gameobjects as unity doesn't like you creating stuff outside start / awake =)...
saikyun
@saikyun
nice that you managed to find a solution :)
Folcon
@Folcon
=)
Folcon
@Folcon
I don't know if anyone else is interested in using Unity's new UIElements stuff for building user interfaces... I've started building a somewhat kooky namespace to start handling / working with these and if anyone wants to give it a go please tell me =)... I'm still trying to figure out how to hook into it gracefully, but it does work, with a small amount of c# which I'd love to eliminate!
Folcon
@Folcon

Anyone have any suggestions on how to specify this interop call?

public static T Q(UIElements.VisualElement e, string name, string className);

From: https://docs.unity3d.com/2019.1/Documentation/ScriptReference/UIElements.UQueryExtensions.Q.html

This is used as:

var label = root.Q<Label>("label-name");

My digging around in the clr docs is that the way to do this is using (type-args UnityEngine.UIElements.Label) to represent the <Label> part:

(UQueryExtensions/Q (type-args Label) (get-root ui-screen) "label-name" "")

Except this always returns nil, stepping through the nrepl evaluation in the debugger makes me believe that it's not finding the function... Except it's not returning an undefined fn error... Really not sure what's going on...

root and get-root are the same as far as I can tell =)...
My delightful workaround for this is to manually create a function for each type, which is viable as there are only finite types that cover this...

Georg Kirsch
@Disney1
Hello! Has anyone here experience with Arcadia and ArFoundation in Unity?
Folcon
@Folcon

I'm seeing references to StrongBox`1, which some googling is telling me is a way of boxing stuff... specifically this? System.Runtime.CompilerServices.StrongBox, except no idea how to construct it. I've tried importing it with no luck.

I tried constructing it via:

(by-ref (uint 0))
(|System.Runtime.CompilerServices.StrongBox`1[uint]|. 1)
(|StrongBox`1[uint]|. 1) ;; wasn't really expecting this to work, but I figured give it a shot =)...

Maybe this is a rabbit hole, what I'm trying to do is use a function that takes out uint x. Any suggestions on how to do this would be great =)...

Reading the clr docs implies that you should use by-ref and though that works for ref's, it doesn't appear to work on out...

Folcon
@Folcon

I think I'm hitting this:
arcadia-unity/Arcadia#114

(Vector3/SmoothDamp (-> obj .transform .forward) target-dir (by-ref smooth-v) smooth-time)

Commonly smooth-v just blows up, and I have no idea how to tell if it's null or not. Any ideas or ways of working with these?

Folcon
@Folcon

Ok, I figured it out, but it involved having to add smoothDamp to LinearHelper:

public static IPersistentVector smoothDamp(Vector3 current, Vector3 target, Vector3 currentVelocity, float smoothTime)
{
     Vector3 newCurrentVelocity = currentVelocity;
     Vector3 result = Vector3.SmoothDamp(current, target, ref newCurrentVelocity, smoothTime);
     return PersistentVector.create(result, newCurrentVelocity);
}

as well as add smooth-damp to arcadia.linear

(definline smooth-damp
  "Given a `Vector3` `current`, a `Vector3` `target` a `Vector3` `current-velocity` and a `float` `smooth-time`, returns a collection containing the result (`Vector3`) of smoothly changing from the current to the target over the time smooth-time and current-velocity (`Vector3`), as set by the `Vector3/SmoothDamp`.

  Calls to this function will be inlined if possible."
  [^UnityEngine.Vector3 current ^UnityEngine.Vector3 target ^UnityEngine.Vector3 current-velocity smooth-time]
  `(Arcadia.LinearHelper/smoothDamp ~current ~target ~current-velocity ~smooth-time))

Happy to PR it (though it will probably need some improvement), as there seems to be precedent with working with ref according to arcadia-unity/Arcadia#267.

Folcon
@Folcon
Btw, is there any existing way of invoking Arcadia => Prepare for Export from the command line?