Example #1
0
 public void LoadFromPreset(RagdollPresetMetadata preset)
 {
     ReleaseBaseTexture();
     savePath = FileTools.Combine(preset.folder, part.ToString() + ".png");
     textureLoadSuppressed = preset.GetPart(part).suppressCustomTexture;
     if (!textureLoadSuppressed)
     {
         RagdollPresetPartMetadata ragdollPresetPartMetadata = preset.GetPart(part);
         if (ragdollPresetPartMetadata != null && ragdollPresetPartMetadata.bytes != null)
         {
             ChangeBaseTexture(FileTools.TextureFromBytes(part.ToString(), ragdollPresetPartMetadata.bytes), isAsset: false);
         }
         else if (!string.IsNullOrEmpty(savePath))
         {
             bool      isAsset;
             Texture2D newRes = FileTools.ReadTexture(savePath, out isAsset);
             ChangeBaseTexture(newRes, isAsset);
         }
         if (baseTexture != null)
         {
             baseTexture.Compress(highQuality: true);
             baseTexture.Apply(updateMipmaps: true);
         }
     }
     if (model.meta.metaPath.StartsWith("builtin"))
     {
         if (baseTexture == null)
         {
             ChangeBaseTexture(HFFResources.instance.FindTextureResource("SkinTextures/" + model.meta.modelPrefab.name + "Color"), isAsset: true);
         }
         if (model.maskTexture == null)
         {
             ChangeMaskTexture(HFFResources.instance.FindTextureResource("SkinTextures/" + model.meta.modelPrefab.name + "Mask"), isAsset: true);
         }
     }
     if (baseTexture != null)
     {
         width           = baseTexture.width;
         height          = baseTexture.height;
         paintingEnabled = true;
     }
     else if (model.maskTexture != null)
     {
         width           = model.maskTexture.width;
         height          = model.maskTexture.height;
         paintingEnabled = true;
     }
     else
     {
         width           = (height = 2048);
         paintingEnabled = true;
     }
 }
Example #2
0
    public void ApplyPresetColors(RagdollPresetMetadata preset, bool bake, bool compress)
    {
        string b = FileTools.Combine(preset.folder, part.ToString() + ".png");
        bool   suppressCustomTexture = preset.GetPart(part).suppressCustomTexture;

        if (savePath != b || textureLoadSuppressed != suppressCustomTexture)
        {
            LoadFromPreset(preset);
        }
        RagdollPresetPartMetadata ragdollPresetPartMetadata = preset.GetPart(part);

        ApplyColors(HexConverter.HexToColor(ragdollPresetPartMetadata.color1, default(Color)), HexConverter.HexToColor(ragdollPresetPartMetadata.color2, default(Color)), HexConverter.HexToColor(ragdollPresetPartMetadata.color3, default(Color)), bake, compress);
    }