创建ScriptsObject和读取

ScriptsObject(SpawnBattleFightArea)结构

[CreateAssetMenu(fileName = "FightArea", menuName = "ScriptableObjects/SpawnBattleFightArea", order = 1)]
public class SpawnBattleFightArea : ScriptableObject
{
    [System.Serializable]
    public class FightAreaPos
    {
        public Vector3 pos;
        public Vector3 rotate;
        public Vector3 scale;
    }
   
    [System.Serializable]
       public class PlayerPos
       {
           public Vector3 onePos;
           public Vector3 oneRotate;
           public Vector3 oneScale;
           public Vector3 twoPos;
           public Vector3 twoRotate;
           public Vector3 twoScale;
       }
   
    public List<FightAreaPos> FightAreaPosDic = new List<FightAreaPos>();
    public List<PlayerPos> PlayerPosDic = new List<PlayerPos>();

ScriptsObject(SpawnBattleSkillScale )结构


[CreateAssetMenu(fileName = "SkillScale", menuName = "ScriptableObjects/SpawnBattleSkillScale", order = 1)]
public class SpawnBattleSkillScale : ScriptableObject
{
    [System.Serializable]
   public class skillScale
   {
      public int skillId;
      public Vector3 Scale;
   }
   
 public List<skillScale> skillScaleDic = new List<skillScale>();

}

ScriptsObject(SpawnBattlePetMat)结构


[CreateAssetMenu(fileName = "BattlePetMat", menuName = "ScriptableObjects/SpawnPetMat", order = 1)]
public class SpawnBattlePetMat : ScriptableObject
{
    [ColorUsage(true,true)]
    public Color _EmissionColor;
    [ColorUsage(true,true)]
    public Color _EmissionAddColor;
    [ColorUsage(true,true)]
    public Color _DissolveColor;
    
    public Color damageColor = Color.red;
}

读取ScriptsObject

  public static SpawnBattlePetMat petMatObj;
    public static SpawnBattleSkillScale skillScaleObj;
    public static SpawnBattleFightArea fightAreaObj;
    //跟加载物体一样
ResourceLoaderHub.Battle.LoadBundle(ABConst.ScriptableObj);
        petMatObj = ResourceLoaderHub.Battle.LoadResource<SpawnBattlePetMat>(ABConst.ScriptableObj, "BattlePetMat");
        skillScaleObj =  ResourceLoaderHub.Battle.LoadResource<SpawnBattleSkillScale>(ABConst.ScriptableObj, "SkillScale");
        fightAreaObj = ResourceLoaderHub.Battle.LoadResource<SpawnBattleFightArea>(ABConst.ScriptableObj, "FightArea");
    

//用代码设置ScriptsObjec里面的值的时候,需要ScriptsObject.setdirty()(是不是这个方法记不清了,反正要有这个步骤),不然你设置的一编译就会丢失

你可能感兴趣的:(游戏开发,c#)