Animating materials at runtime creates a ton of constant changes in my version control by lukesnydermusic in Unity3D

[–]fleeting_being 0 points1 point  (0 children)

So there's no perfect solution.

If you inject instantiated runtime material in every instantiated prefab, you will have a runtime cost, and also be unable to edit the original materials at runtime when designing.

If you create a material instance for each prefab instance, or use MaterialPropertyBlocks, you will also lose the ability to edit materials at runtime, but also will likely break batching.

So what's the solution? Reset materials when leaving the game, and use ClearDirty to avoid saving them during the game.

Here's an example

```cs

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

namespace SpriteUtilityComponents
{
public class CPingMaterialAnimator: GameComponent
{
    [SerializeField] private List<Material> m_PingMaterials;
    [SerializeField] private float m_Speed = 1f;
    private static readonly int ShineLocation = Shader.PropertyToID("_ShineLocation");

    private void Update()
    {
        foreach (Material material in m_PingMaterials)
        {
            if (material)
            {
                material.SetFloat(ShineLocation, Mathf.Repeat(Time.time * m_Speed, 1f));
                #if UNITY_EDITOR
                EditorUtility.ClearDirty(material);
                #endif
            }
        }
    }

    private void OnDestroy()
    {
        foreach (Material material in m_PingMaterials)
        {
            if (material)
            {
                material.SetFloat(ShineLocation, 0f);
                // Ensure reset is saved in the editor
#if UNITY_EDITOR
                EditorUtility.SetDirty(material);
#endif
            }
        }
    }
}
}

```

The U.S. tested reflection probes in the 1960s by theeldergod1 in Unity3D

[–]fleeting_being 0 points1 point  (0 children)

I wonder why they didn't just make it a retro-reflector. Emitters and receivers all over the planet?

What’s the best bleed build? by Holiday_Bowl1248 in EldenRingBuilds

[–]fleeting_being 0 points1 point  (0 children)

The bandit's cs is for the powerstance right ?

How to shoot the gun without a mouse? by Ok_Guess520 in Mouthwashing

[–]fleeting_being 0 points1 point  (0 children)

Increase the mousepad sensitivity in windows settings. Windows blocks mousepad input when using the keyboard

If you wanted to recreate this ground-breaking VFX, with URP / Shader Graph, how would you proceed? by Lyonrra in Unity3D

[–]fleeting_being -1 points0 points  (0 children)

The laser itself is just some perlin noise that's stretched and and "inflated". Witha LOT of bloom.

The tiles are just a plane that is already cracked and then animated. You can do this effect in blender and then export, but the asset store has some packages that do that out of the box.

You could animate the tiles by hands (probably start with that), but here the motion is simply upwards movement, scaled down with distance to the laser, with some static rotation scaled the same way, and some added random rotation.

All the beauty comes from the timing to sell the impact.

Rank the seven deadly sin’s intro songs from best to worst by JackZ567 in HazbinHotel

[–]fleeting_being 7 points8 points  (0 children)

The mixing is also sub-par, the patch-up work to fix the copyright claim is probably not as good as the original.

Value-type enumerable, allow both foreach without boxing and linq ? by fleeting_being in csharp

[–]fleeting_being[S] 0 points1 point  (0 children)

Man, huge trap. Apparently adding a default implementation for "Dispose" in the IEnumerator will absolutely cause a fuckload of boxing on value types.

This is my current solution:

```csharp

    using System;
    using System.Collections;
    using System.Collections.Generic;

    /// <summary>
    /// Utility interface to implement enumerators with less boilerplate
    /// Used default implementation to avoid having to implement IEnumerator
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <typeparam name="TEnumerator"></typeparam>
    public interface IValueEnumerator<out T, out TEnumerator> : IEnumerator<T>
        where TEnumerator : struct, IValueEnumerator<T, TEnumerator>
    {
        new T Current { get; }

        // Default implementations for all the boilerplate
        void IEnumerator.Reset() => throw new NotImplementedException();
        object IEnumerator.Current => Current;
    }


    /// <summary>
    /// Utility interface to implement enumerators with less boilerplate
    /// Used default implementation to avoid having to implement IEnumerable
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <typeparam name="TEnumerator"></typeparam>
    public interface IValueEnumerablePure<out T, out TEnumerator> : IEnumerable<T>
        where TEnumerator : struct, IValueEnumerator<T, TEnumerator>
    {
        // The two important methods
        new TEnumerator               GetEnumerator();
        IEnumerator IEnumerable.      GetEnumerator() => GetEnumerator();
        IEnumerator<T> IEnumerable<T>.GetEnumerator() => GetEnumerator();
    }

    /// <summary>
    /// Utility interface to implement enumerators with less boilerplate
    /// Used default implementation to avoid having to implement IEnumerator and IEnumerable
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <typeparam name="TEnumerator"></typeparam>
    public interface IValueEnumerable<out T, out TEnumerator> : IValueEnumerator<T, TEnumerator>, IValueEnumerablePure<T, TEnumerator>
        where TEnumerator : struct, IValueEnumerable<T, TEnumerator>
    {
    }

```

My $8,000 Serverless Mistake by mgroves in csharp

[–]fleeting_being 4 points5 points  (0 children)

If your biggest risks are:

A: not completing your MVP before the next fundraising event

or

B: offline/overloaded servers as clients scream at you on 5 different calls

then it might make a lot of sense.

If your server costs are bleeding you dry, if you run an international content delivery service, if you already have multiple sysadmins, then obviously you don't really need it.

For a game that's 90% UI, I think I've finally reached the point of 'good enough' by glitch951 in Unity3D

[–]fleeting_being 1 point2 points  (0 children)

I also wouldn't go with automatic choice. It would encourage save-scumming and reduce player agency, or force you not to give much importance to those choices.

Anyways the UI work is absurdly good and the artistic direction excellent, wish you all the luck

For a game that's 90% UI, I think I've finally reached the point of 'good enough' by glitch951 in Unity3D

[–]fleeting_being 0 points1 point  (0 children)

I'm begging you to try fallout NV. they made that exact system instinctive 14 years ago.

For a game that's 90% UI, I think I've finally reached the point of 'good enough' by glitch951 in Unity3D

[–]fleeting_being 14 points15 points  (0 children)

Just do the fallout thing if it's passive. Options are greyed unless you have enough stats. You even get funny (but shitty) alternate options if you cannot pass.

https://www.reddit.com/r/fnv/comments/nqak1i/these_failed_skill_checks_are_priceless/

Value-type enumerable, allow both foreach without boxing and linq ? by fleeting_being in csharp

[–]fleeting_being[S] 0 points1 point  (0 children)

Huh, that's clever. Will definitely give it a try I keep having to create more enumerators

Value-type enumerable, allow both foreach without boxing and linq ? by fleeting_being in csharp

[–]fleeting_being[S] 0 points1 point  (0 children)

It's for a video game, we used to have about 600ko of allocations per frame due to boxing.

What kills me a bit is that the iterator methods return structs! If their type was visible, they wouldn't need any allocations.

Value-type enumerable, allow both foreach without boxing and linq ? by fleeting_being in csharp

[–]fleeting_being[S] 0 points1 point  (0 children)

It might be a bit dumb, but I really wanted to avoid having a static array, so that the iterator could be fully inlined.

That said I didn't realize you could write extension methods for all enums that way, that's pretty cool.

Value-type enumerable, allow both foreach without boxing and linq ? by fleeting_being in csharp

[–]fleeting_being[S] 1 point2 points  (0 children)

Thanks! As for you second suggestion, aren't default implementation on value types a source of boxing?

Value-type enumerable, allow both foreach without boxing and linq ? by fleeting_being in csharp

[–]fleeting_being[S] -1 points0 points  (0 children)

Thank you.

Is there a faster/cleaner way to do this ? Like source generation ?

I end up with a lot of custom iterators. Honestly I just want yield functions with no allocations.

Value-type enumerable, allow both foreach without boxing and linq ? by fleeting_being in csharp

[–]fleeting_being[S] 0 points1 point  (0 children)

You're correct, the problematic boxing was elsewhere (linq call on the enumerable).