Search Unity

Creating a Color Preset Library Asset from C# Script

Discussion in 'Scripting' started by conigliocattivo, Oct 20, 2017.

  1. conigliocattivo

    conigliocattivo

    Joined:
    May 14, 2013
    Posts:
    10
    Hello everyone,

    I am making a small Editor Tool and I need to save a Color Preset Library from my code. I already created the proper class (inspired by https://github.com/MattRix/UnityDec...UnityEditor/UnityEditor/ColorPresetLibrary.cs) and I can make an asset out of it as a normal Scriptable Object. The problem is that the asset is not recognized by Unity as a Library Preset. Opening a working Library Preset and the one I created I found that the only difference is in this line:

    in my file:
    m_Script: {fileID: 11500000, guid: d4c76a0efd6d44b219b4680bd89cb948, type: 3}
    in the Color Library Preset created by Unity:
    m_Script: {fileID: 12323, guid: 0000000000000000e000000000000000, type: 0}

    If I manually modify it, the asset is then properly recognized by Unity.
    Since this property is created automatically when I save the scriptable object, is there any way to force these values? Or maybe is there a better way to create a Color Library Preset from a script?

    Hope someone can help!
    Thanks!

    Antonio
     
  2. awardell

    awardell

    Joined:
    Feb 5, 2014
    Posts:
    71
    Did you ever find your answer for how to accomplish this? I am looking to do the same sort of thing.