#A dumb C# Beginner Requiring Help

1 messages · Page 1 of 1 (latest)

pastel flax
#

Just moving here to de-clutter and cause I'm worried I'm getting on peoples nerves lol. So I now know it isn't IDE'd crorrectly I think? Because the assembly thing isn't there, all I see is the miscelanious thing. But how do I change that? The IDE links didn't really help

#

Also why is it yellow, does that mean theres an error?

#

I also noticed where it says "public class FindAnimationClips" is supposed to be the name of the .cs file. I changed the name of the file to that but still nothing

unborn lion
#

Can you go to your console window in Unity and make sure that there are no errors

pastel flax
#

There are PrecompiledAssemblyException errors but for a different script

unborn lion
#

Any compiler errors will stop all scripts from compiling

#

Why do you have two versions of Harmony?

pastel flax
#

I have no clue what it is, it just came with two different packages, the VRchat one and the CEditor thng I bought. Ill delete one of them now

#

So I deleted it and it spat out 68 new errors

#

But their not compilor errors right?

unborn lion
#

Yes, they are

#

Perhaps restart Unity, and then you will need start at the top of the errors if they're still there

pastel flax
#

Good news is it isn't miscelanoius anymore?

pastel flax
#

Is there a dumbass role? I think I need it 😂

unborn lion
#

You should be able to remove the underlined = new() in the above script and it should hopefully still work; if not you'll need to do new List<AnimationClip>().

somber cape
#

ahh right .. old Unity

#

was about to say why would new() error xD

#

new c# flex

unborn lion
#

"new" C#

somber cape
#

*unity standards xD

pastel flax
#

Closed and re-opened the project but the errors are all still there

#

Its nearly 4am here I'm gonna sleep and come back tomorrow lmao, Im sorry for being so dumb guys 😅

unborn lion
#

🤷 you're learning, and listening, which is much better than many others 😄

pastel flax
#

Haha thank you 😊

somber cape
#

Im thinking you had 2 assets or something, using the same library and probably had 2 copies

#

not sure though, you might have some asemdef references to fix

pastel flax
#

Hai! I'm sorry for not trying yesterday, some personal reasons. But yeah! I cleared all the Poiomi compilor errors, and now am just facing these two with the script

#

I also noticed this if it helps?

#

For anyone new looking here, here is the full script:

using System.Collections.Generic;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;

public class FindAnimationClips : EditorWindow
{
    [SerializeField]
    private List<AnimationClip> _clips = new();

    private void OnEnable()
    {
        var serializedObject = new SerializedObject(this);
        rootVisualElement.Add(new Button(GetAllClips) { text = "Get all clips" });
        rootVisualElement.Add(new Button(SetToLoop) { text = "Get clips set to loop" });
        rootVisualElement.Add(new Button(Unloop) { text = "Get clips set to not loop" });
        rootVisualElement.Add(new PropertyField { bindingPath = nameof(_clips) });
        rootVisualElement.Bind(serializedObject);
    }

    [MenuItem("Tools/Find Animation Clips")]
    private static void Open() => GetWindow<FindAnimationClips>().Show();

    private void GetAllClips()
    {
        string[] guids1 = AssetDatabase.FindAssets("t:AnimationClip", null);

        foreach (string guid1 in guids1)
        {
            Debug.Log(AssetDatabase.GUIDToAssetPath(guid1));

            AnimationClip animClip = AssetDatabase.LoadAssetAtPath<AnimationClip>(AssetDatabase.GUIDToAssetPath(guid1));

            if (!_clips.Contains(animClip))
            {
                _clips.Add(animClip);
            }
        }
    }

    private void SetToLoop() => CanLoop(true);

    private void Unloop() => CanLoop(false);

    private void CanLoop(bool canLoop)
    {
        foreach (AnimationClip clip in _clips)
        {
            var settings = AnimationUtility.GetAnimationClipSettings(clip);
            settings.loopTime = canLoop;
            AnimationUtility.SetAnimationClipSettings(clip, settings);
        }
    }
}
static rose
#

You cannot use new() because the C# version coming with your Unity project isn't recent enough. You have C# 7.3, using new() requires C# 9 or newer.
Use = new List<AnimationClip>();, the long form that was there sonce the beginning of C#

#

Or none at all actually, since you serialize the field, Unity will create it for you for displaying in the Inspector

pastel flax
#

Okay! Doesn't seem to be any compilor errors there now!

#

Also it won't be in inspector, its a tools dropdown

#

Ayy it shows up now!!

static rose
#

If it shows up, it's in the Inspector

somber cape
#

sweet so its working?

static rose
#

Little to no knowledge of coding, and programming an Editor window on what seems like a VRChat addon? Seems a bit audacious

somber cape
static rose
#

lol

pastel flax
somber cape
#

i started the script, vertx ofc made it like much cleaner

pastel flax
#

It did work but it sets every animation in the whole project to loop or not loop. Would it be possible to be able to drag in specific clips to change?

somber cape
#

weird af

somber cape
#

or just dont do Get All and put inside the clips hyou want

pastel flax
somber cape
#

you have to drag the clips inside the Label

pastel flax
somber cape
#

strange..

somber cape
static rose
somber cape
pastel flax
pastel flax
somber cape
pastel flax
#

Then again, I have somany animations it could be too much to handle?

somber cape
#

did you completely remove new() or did you ptu new List<AnimationClips>

somber cape
pastel flax
#

1,007 to be exact

somber cape
#

you dont have to do 1 at a time

#

you can drag all clips in here

#

and it will fill it for u

pastel flax
somber cape
#

okie

pastel flax
somber cape
#

No i meant remove them all and drag the clips inside without pressing GetAll

#

im going to try something real quick

pastel flax
#

Sure!

#

Heres the script again:

using System.Collections.Generic;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;

public class FindAnimationClips : EditorWindow
{
    [SerializeField]
    private List<AnimationClip> _clips = new List<AnimationClip>();

    private void OnEnable()
    {
        var serializedObject = new SerializedObject(this);
        rootVisualElement.Add(new Button(GetAllClips) { text = "Get all clips" });
        rootVisualElement.Add(new Button(SetToLoop) { text = "Get clips set to loop" });
        rootVisualElement.Add(new Button(Unloop) { text = "Get clips set to not loop" });
        rootVisualElement.Add(new PropertyField { bindingPath = nameof(_clips) });
        rootVisualElement.Bind(serializedObject);
    }

    [MenuItem("Tools/Find Animation Clips")]
    private static void Open() => GetWindow<FindAnimationClips>().Show();

    private void GetAllClips()
    {
        string[] guids1 = AssetDatabase.FindAssets("t:AnimationClip", null);

        foreach (string guid1 in guids1)
        {
            Debug.Log(AssetDatabase.GUIDToAssetPath(guid1));

            AnimationClip animClip = AssetDatabase.LoadAssetAtPath<AnimationClip>(AssetDatabase.GUIDToAssetPath(guid1));

            if (!_clips.Contains(animClip))
            {
                _clips.Add(animClip);
            }
        }
    }

    private void SetToLoop() => CanLoop(true);

    private void Unloop() => CanLoop(false);

    private void CanLoop(bool canLoop)
    {
        foreach (AnimationClip clip in _clips)
        {
            var settings = AnimationUtility.GetAnimationClipSettings(clip);
            settings.loopTime = canLoop;
            AnimationUtility.SetAnimationClipSettings(clip, settings);
        }
    }
}
somber cape
#

no worries I have it 😛

#

it could also be possible that its a lot of clips and it freaks out the editor lol

pastel flax
#

I was thinking. if getting all animations is a case of doing "AssetDatabase.FindAssets("t:AnimationClip", null)" couldn't I have a search box and have it do this AssetDatabase.FindAssets("t:AnimationClip", [search], null)

#

Or soemthing

#

I'm assuming I would also need to do var Search = typebox or something, idk the script for an input box lol

somber cape
#

FindAssets has no such thing

#

the first field is the searchname

#

it can probably be combined with a name possibly, i have to look into the search string format

pastel flax
#

Its my stupid way of learning lmao

somber cape
#

haha yeah starting from editor scripting wouldn't be the easiest

pastel flax
#

LMAO probably not, but I changed the name of it in tools!

#

Anyway, Ill stop bugging you wheil you look at the black box thing

somber cape
#

hmm yea not seeing any black boxes on this end

#

try just doing it in batches maybe ?

#

or did you try manually dragging them in the list

#

all at once

pastel flax
#

So clicking get all, it does get all and I can actually toggle all on or off, however it displays a black box. Its a visual big not a functional bug

somber cape
#

not sure if it has to do with something 2019 specific or too many elements for an editor array

#

I dont have that many clips to test anyway

#

You can try adding this line under rootVisualElement.Bind(serializedObject);
serializedObject.ApplyModifiedProperties();

#

but doubt it, it just fixes some other error i found

#

if it works though functionally nothing you should worry about

pastel flax
#

Sure! Will try now

#

If you want to, I am happy to export the whole project as .unitypackage file and send it to you so you can see?

somber cape
pastel flax
#

@unborn lion @somber cape Hai! Do you mind if I put this up for free on Gumroad? Happy to credit any websites or pages of yours in it too, will already credit your discords

unborn lion
#

Do whatever you want with it UnityChanThumbsUp