#A dumb C# Beginner Requiring Help
1 messages · Page 1 of 1 (latest)
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
Can you go to your console window in Unity and make sure that there are no errors
There are PrecompiledAssemblyException errors but for a different script
Any compiler errors will stop all scripts from compiling
Why do you have two versions of Harmony?
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?
Yes, they are
Perhaps restart Unity, and then you will need start at the top of the errors if they're still there
Good news is it isn't miscelanoius anymore?
Sure!
Is there a dumbass role? I think I need it 😂
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>().
"new" C#
*unity standards xD
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 😅
🤷 you're learning, and listening, which is much better than many others 😄
Haha thank you 😊
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
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);
}
}
}
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
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!!
If it shows up, it's in the Inspector
sweet so its working?
Little to no knowledge of coding, and programming an Editor window on what seems like a VRChat addon? Seems a bit audacious
also they did tell you last time 😛
lol
Oh god hahaha
its more of a quickfix for shortcoming of unity editor
i started the script, vertx ofc made it like much cleaner
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?
apparently unity cant multi-edit fields when multiple animation clips are selected
weird af
yes just remove the ones you dont want in the list
or just dont do Get All and put inside the clips hyou want
VRChat Addon? no just an addon to help working with unity a little less painfull lol
you have to drag the clips inside the Label
Ohh it broke before and showed like a black box when I clicked get all lol
strange..
did you completely remove the new part ?
Saw various VR toolbar items on a screenshot, so assumed it was a mod or plugin. I guess this is installed machine-wide and not per project
can you try again and screenshot
Nah, for avatars you can't have any scripts whatsoever. Only worlds can have custom scripts
thats weird
Then again, I have somany animations it could be too much to handle?
did you completely remove new() or did you ptu new List<AnimationClips>
also you can multiple select them and drag them inside the array
1,007 to be exact
you dont have to do 1 at a time
you can drag all clips in here
and it will fill it for u
Removed
private List<AnimationClip> _clips = new();
to
private List<AnimationClip> _clips = new List<AnimationClip>();
okie
Hiding and unhiding that little menu just hides and unhides the black box (I'm assuming that black is the size 1,007?)
No i meant remove them all and drag the clips inside without pressing GetAll
im going to try something real quick
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);
}
}
}
no worries I have it 😛
it could also be possible that its a lot of clips and it freaks out the editor lol
True lol
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
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
Ah nvm then. Was just looking through the code to see how exactly it works to see what changes I could make
Its my stupid way of learning lmao
haha yeah starting from editor scripting wouldn't be the easiest
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
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
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
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
Sure! Will try now
Nope
If you want to, I am happy to export the whole project as .unitypackage file and send it to you so you can see?
hmm sure or maybe just the animations ?
won't be able to test till in the am tomorrow though
@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
Do whatever you want with it 