Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix warnings #568

Merged
merged 1 commit into from Sep 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 23 additions & 6 deletions Assets/VRM/UniVRM/Editor/SkinnedMeshUtility/SkinnedMeshUtility.cs
Expand Up @@ -9,7 +9,7 @@ public static class SkinnedMeshUtility
{
public const string MENU_KEY = "GameObject/UnityEditorScripts/";
public const int MENU_PRIORITY = 11;

public static Object GetPrefab(GameObject instance)
{
#if UNITY_2018_2_OR_NEWER
Expand All @@ -21,22 +21,39 @@ public static Object GetPrefab(GameObject instance)

public static bool IsPrefab(Object instance)
{
return instance != null && PrefabUtility.GetPrefabType(instance) == PrefabType.Prefab;
if (instance == null)
{
return false;
}
if (PrefabUtility.GetPrefabAssetType(instance) != PrefabAssetType.Regular)
{
return false;
}
return true;
}

public static void ApplyChangesToPrefab(GameObject instance)
{
var prefab = GetPrefab(instance);
if (prefab == null) return;
if (prefab == null)
{
return;
}

var path = AssetDatabase.GetAssetPath(prefab);
if (string.IsNullOrEmpty(path))
{
return;
}

PrefabUtility.ReplacePrefab(instance, prefab, ReplacePrefabOptions.ConnectToPrefab);
PrefabUtility.SaveAsPrefabAssetAndConnect(instance, path, InteractionMode.AutomatedAction);
}

public static GameObject InstantiatePrefab(GameObject prefab)
{
if (!IsPrefab(prefab)) return null;

return (GameObject) PrefabUtility.InstantiatePrefab(prefab);
return (GameObject)PrefabUtility.InstantiatePrefab(prefab);
}
}
}