コード例 #1
0
        protected override void Logic(ValidationTarget target)
        {
            //var dependenciesFolderPath = AssetDatabase.GUIDToAssetPath(VRCSDKDependenciesFolderGUID);
            //var rootFolderPath = Path.GetDirectoryName(dependenciesFolderPath);
            //var versionFilePath = Path.Combine(rootFolderPath, "version.txt");

            /*if (string.IsNullOrEmpty(rootFolderPath) ||
             *  string.IsNullOrEmpty(versionFilePath) ||
             *  !File.Exists(versionFilePath))*/
            if (!File.Exists(versionFilePath))
            {
                AddIssue(new Issue(null,
                                   IssueLevel.Error,
                                   LocalizedMessage.Get("VRCSDKVersionRule.NotInstalled"),
                                   LocalizedMessage.Get("VRCSDKVersionRule.NotInstalled.Solution"),
                                   solutionURL: downloadURL
                                   ));
                return;
            }

            var currentVersion = new VRCSDKVersion(File.ReadAllText(versionFilePath));

            if (currentVersion < targetVersion)
            {
                AddIssue(new Issue(null,
                                   IssueLevel.Error,
                                   LocalizedMessage.Get("VRCSDKVersionRule.PreviousVersion"),
                                   LocalizedMessage.Get("VRCSDKVersionRule.PreviousVersion.Solution"),
                                   solutionURL: downloadURL
                                   ));
            }
        }
コード例 #2
0
        protected override void Logic(ValidationTarget target)
        {
            if (unusableBakeTypes.Length <= 0)
            {
                return;
            }

            var objs = target.GetAllObjects();

            foreach (var obj in objs)
            {
                var light = obj.GetComponent <Light>();

                if (light != null && light.type == type)
                {
                    if (unusableBakeTypes.Contains(light.lightmapBakeType))
                    {
                        AddIssue(new Issue(
                                     obj,
                                     IssueLevel.Error,
                                     LocalizedMessage.Get("UseLightModeRule.MustNotUse", type, light.lightmapBakeType),
                                     LocalizedMessage.Get("UseLightModeRule.MustNotUse.Solution")
                                     ));
                    }
                }
            }
        }
コード例 #3
0
ファイル: Validator.cs プロジェクト: Kozu-vr/VitDeck
 private static void RegisterUndo(ValidationTarget target)
 {
     foreach (var rootObject in target.GetRootObjects())
     {
         Undo.RegisterFullObjectHierarchyUndo(rootObject, "Validate");
     }
 }
コード例 #4
0
        protected override void Logic(ValidationTarget target)
        {
            var loadedScenes = new HashSet <Scene>(GetLoadedScenes());
            var targetScenes = target.GetScenes();

            foreach (var scene in targetScenes)
            {
                loadedScenes.Remove(scene);
            }

            foreach (var unrelatedScene in loadedScenes)
            {
                var message     = LocalizedMessage.Get("SceneStructureRule.UnrelatedSceneDetected", unrelatedScene.name);
                var solution    = LocalizedMessage.Get("SceneStructureRule.UnrelatedSceneDetected.Solution");
                var solutionURL = LocalizedMessage.Get("SceneStructureRule.UnrelatedSceneDetected.SolutionURL");

                var sceneAsset = AssetDatabase.LoadAssetAtPath <SceneAsset>(unrelatedScene.path);
                AddIssue(new Issue(sceneAsset, IssueLevel.Error, message, solution, solutionURL));
            }

            foreach (var targetScene in targetScenes)
            {
                ValidateRootObject(target, targetScene);
            }
        }
コード例 #5
0
        protected override void Logic(ValidationTarget target)
        {
            var assets = target.GetAllAssets();

            List <Object> foundAssets = new List <Object>();

            foreach (var asset in assets)
            {
                if (asset.GetType() == type &&
                    !excludedAssetGUIDs.Contains(GetGUID(asset)))
                {
                    foundAssets.Add(asset);
                }
            }

            if (foundAssets.Count > limit)
            {
                var message  = LocalizedMessage.Get("AssetTypeLimitRule.Overuse", type.Name, limit, foundAssets.Count);
                var solution = LocalizedMessage.Get("AssetTypeLimitRule.Overuse.Solution", type.Name);

                AddIssue(new Issue(
                             null,
                             IssueLevel.Error,
                             message,
                             solution));
            }
        }
コード例 #6
0
        protected override void Logic(ValidationTarget target)
        {
            var scenes = target.GetScenes();

            // 全てリアルタイムであればlightmapの検証は不要
            var staticRenderersCount = target.GetAllObjects()
                                       .Where(IsWrittenToLightmap)
                                       .SelectMany(obj => obj.GetComponents <Renderer>())
                                       .Count();

            if (staticRenderersCount == 0)
            {
                return;
            }

            foreach (var scene in scenes)
            {
                LogicForScene(scene);
            }

            if (IsLightMapAutoGenerated())
            {
                AddIssue(new Issue(
                             null,
                             IssueLevel.Error,
                             LocalizedMessage.Get("LightmapSizeLimitRule.MustLightmapBakingManually"),
                             LocalizedMessage.Get("LightmapSizeLimitRule.MustLightmapBakingManually.Solution")));
            }
        }
コード例 #7
0
        protected override void Logic(ValidationTarget target)
        {
            var objs = target.GetAllObjects();

            var foundLights = new List <Light>();

            foreach (var obj in objs)
            {
                var light = obj.GetComponent <Light>();
                if (light != null && light.type == type)
                {
                    foundLights.Add(light);
                }
            }

            if (foundLights.Count > limit)
            {
                var message  = LocalizedMessage.Get("LightCountLimitRule.Overuse", type, limit, foundLights.Count);
                var solution = LocalizedMessage.Get("LightCountLimitRule.Overuse.Solution");

                foreach (var light in foundLights)
                {
                    AddIssue(new Issue(
                                 light,
                                 IssueLevel.Error,
                                 message,
                                 solution));
                }
            }
        }
コード例 #8
0
        protected override void Logic(ValidationTarget target)
        {
            if (targetType == null)
            {
                return;
            }

            foreach (var gameObject in target.GetAllObjects())
            {
                var components = gameObject.GetComponents(targetType);

                if (components.Length == 0)
                {
                    continue;
                }

                if (!HasVisibleComponents(components))
                {
                    continue;
                }

                HasComponentObjectLogic(gameObject);

                foreach (var component in components)
                {
                    ComponentLogic(component);
                }
            }
        }
コード例 #9
0
        protected override void Logic(ValidationTarget target)
        {
            var extList = new List <string>();

            foreach (var extention in extentions)
            {
                if (!string.IsNullOrEmpty(extention))
                {
                    var ext = extention.StartsWith(".") ? extention : "." + extention;
                    extList.Add(ext);
                }
                else
                {
                    // ユーザーが対処できるメッセージではないのでコメントアウト
                    //AddIssue(new Issue(null, IssueLevel.Warning, "設定された拡張子は空文字のため無視されます。", string.Empty, string.Empty));
                }
            }
            var hitPaths = target.GetAllAssetPaths()
                           .Where(targetPath => extList.Exists(ext => ext.Equals(Path.GetExtension(targetPath), StringComparison.InvariantCultureIgnoreCase)));
            var baseFolderPath = target.GetBaseFolderPath();

            foreach (var path in hitPaths)
            {
                if (AssetDatabase.IsValidFolder(path) || !path.StartsWith(baseFolderPath))
                {
                    continue;
                }
                var obj     = AssetDatabase.LoadMainAssetAtPath(path);
                var message = LocalizedMessage.Get("AssetExtentionBlacklistRule.UnauthorizedExtention", Path.GetExtension(path)) + Environment.NewLine + path;
                AddIssue(new Issue(obj, IssueLevel.Error, message, string.Empty, string.Empty));
            }
        }
コード例 #10
0
        protected override void Logic(ValidationTarget target)
        {
            var extList = new List <string>();

            foreach (var extention in extentions)
            {
                if (!string.IsNullOrEmpty(extention))
                {
                    var ext = extention.StartsWith(".") ? extention : "." + extention;
                    extList.Add(ext);
                }
                else
                {
                    AddIssue(new Issue(null, IssueLevel.Warning, "設定された拡張子は空文字のため無視されます。", string.Empty, string.Empty));
                }
            }
            var hitPaths = target.GetAllAssetPaths()
                           .Where(targetPath => extList.Exists(ext => ext.Equals(Path.GetExtension(targetPath), StringComparison.InvariantCultureIgnoreCase)));

            foreach (var path in hitPaths)
            {
                if (AssetDatabase.IsValidFolder(path))
                {
                    continue;
                }
                var obj     = AssetDatabase.LoadMainAssetAtPath(path);
                var message = string.Format("拡張子が`{0}`のアセットが検出されました。", Path.GetExtension(path)) + Environment.NewLine + path;
                AddIssue(new Issue(obj, IssueLevel.Error, message, string.Empty, string.Empty));
            }
        }
コード例 #11
0
        protected override void Logic(ValidationTarget target)
        {
            var objects = target
                          .GetAllObjects()
                          .Where(obj => PrefabUtility.GetPrefabInstanceStatus(obj) == PrefabInstanceStatus.Connected)
                          .Select(PrefabUtility.GetOutermostPrefabInstanceRoot)
                          .Distinct()
                          .Where(IsTargetPrefabInstance)
                          .ToArray();

            if (objects.Length > limit)
            {
                var message     = LocalizedMessage.Get("PrefabLimitRule.Overuse", limit, objects.Length);
                var solution    = LocalizedMessage.Get("PrefabLimitRule.Overuse.Solution");
                var solutionURL = LocalizedMessage.Get("PrefabLimitRule.Overuse.SolutionURL");

                AddIssue(new Issue(
                             null,
                             IssueLevel.Error,
                             message,
                             solution,
                             solutionURL
                             ));
            }
        }
コード例 #12
0
        protected override void Logic(ValidationTarget target)
        {
            foreach (var obj in target.GetAllObjects())
            {
                var components = obj.GetComponents <Component>();
                foreach (var cmp in components)
                {
                    if (cmp == null || cmp.GetType() == typeof(Transform))
                    {
                        continue;
                    }
                    var message = "";
                    foreach (var reference in references)
                    {
                        if (reference != null && reference.Exists(cmp))
                        {
                            switch (reference.level)
                            {
                            case ValidationLevel.ALLOW:
                                break;

                            case ValidationLevel.DISALLOW:
                                message = string.Format("{0}:{1}の使用は許可されていません。", reference.name, cmp.GetType().Name);
                                AddIssue(new Issue(obj, IssueLevel.Error, message, string.Empty, string.Empty));
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #13
0
ファイル: ErrorShaderRule.cs プロジェクト: Kozu-vr/VitDeck
        protected override void Logic(ValidationTarget target)
        {
            foreach (var obj in target.GetAllObjects())
            {
                if (obj.GetComponent <Renderer>() == null)
                {
                    continue;
                }

                var materials = obj.GetComponent <Renderer>().sharedMaterials;

                foreach (var material in materials)
                {
                    if (material == null)
                    {
                        AddIssue(new Issue(obj, IssueLevel.Info, "オブジェクトのRendererにマテリアルの参照がありません。", string.Empty, string.Empty));
                        continue;
                    }

                    if (material.shader.name == "Hidden/InternalErrorShader")
                    {
                        AddIssue(new Issue(obj, IssueLevel.Error, "オブジェクトのマテリアルで正しいシェーダーが参照されていません。", string.Empty, string.Empty));
                        continue;
                    }

                    if (material.shader.name == string.Empty || material.shader.name == null)
                    {
                        AddIssue(new Issue(obj, IssueLevel.Error, "オブジェクトでシェーダーエラーが検出されました。", string.Empty, string.Empty));
                    }
                }
            }
        }
コード例 #14
0
        protected override void Logic(ValidationTarget target)
        {
            var objs = target.GetAllObjects();

            foreach (var obj in objs)
            {
                LogicForObject(obj);
            }
        }
コード例 #15
0
 protected override void Logic(ValidationTarget target)
 {
     if (Application.unityVersion != version)
     {
         var message  = string.Format("実行中のUnityのバージョン({0})が指定されたバージョンと異なっています。", Application.unityVersion);
         var solution = string.Format("バージョン({0})を使用してください。", version);
         AddIssue(new Issue(null, IssueLevel.Error, message, solution, string.Empty));
     }
 }
コード例 #16
0
        protected override void Logic(ValidationTarget target)
        {
            var rootObjs = target.GetRootObjects();

            foreach (var rootObj in rootObjs)
            {
                LogicForRootObject(rootObj);
            }
        }
コード例 #17
0
ファイル: UnityVersionRule.cs プロジェクト: VitDeck/VitDeck
 protected override void Logic(ValidationTarget target)
 {
     if (Application.unityVersion != version)
     {
         var message  = LocalizedMessage.Get("UnityVersionRule.InvalidVersion", Application.unityVersion);
         var solution = LocalizedMessage.Get("UnityVersionRule.InvalidVersion.Solution", version);
         AddIssue(new Issue(null, IssueLevel.Error, message, solution, string.Empty));
     }
 }
コード例 #18
0
        protected override void Logic(ValidationTarget target)
        {
            var objs = target.GetAllObjects()
                       .Where(IsTargetPrefabInstanceRoot);

            foreach (var obj in objs)
            {
                LogicForPrefabInstanceRoot(obj);
            }
        }
コード例 #19
0
ファイル: NoneMeshRule.cs プロジェクト: Kozu-vr/VitDeck
        protected override void Logic(ValidationTarget target)
        {
            var gameObjects = target.GetAllObjects();

            foreach (var gameObject in gameObjects)
            {
                foreach (var component in gameObject.GetComponents <Component>())
                {
                    if (component == null)
                    {
                        continue;
                    }

                    var meshCollider = component as MeshCollider;
                    if (meshCollider != null && meshCollider.sharedMesh == null)
                    {
                        var issue = new Issue(meshCollider, IssueLevel.Error, meshCollider + "にメッシュが設定されていません。");
                        AddIssue(issue);
                        continue;
                    }

                    var meshFilter = component as MeshFilter;
                    if (meshFilter != null && meshFilter.sharedMesh == null)
                    {
                        var issue = new Issue(meshFilter, IssueLevel.Error, meshFilter + "にメッシュが設定されていません。");
                        AddIssue(issue);
                        continue;
                    }

                    var skinnedMeshRenderer = component as SkinnedMeshRenderer;
                    if (skinnedMeshRenderer != null && skinnedMeshRenderer.sharedMesh == null)
                    {
                        var issue = new Issue(skinnedMeshRenderer, IssueLevel.Error, skinnedMeshRenderer + "にメッシュが設定されていません。");
                        AddIssue(issue);
                        continue;
                    }

                    var particleSystem = component as ParticleSystem;
                    if (particleSystem != null)
                    {
                        var shapeModule = particleSystem.shape;
                        if (shapeModule.shapeType == ParticleSystemShapeType.Mesh &&
                            shapeModule.meshShapeType != ParticleSystemMeshShapeType.Vertex &&
                            shapeModule.mesh == null)
                        {
                            var issue = new Issue(particleSystem, IssueLevel.Error, particleSystem + "/Shapeがメッシュに依存する設定であるにも関わらず、メッシュが設定されていません。");
                            AddIssue(issue);
                        }
                        continue;
                    }
                }
            }
        }
コード例 #20
0
        protected override void Logic(ValidationTarget target)
        {
            var hitObjectPaths = target.GetAllAssetGuids()
                                 .Where(targetGuid => Array.Exists(guids, guid => guid == targetGuid))
                                 .Select(guid => AssetDatabase.GUIDToAssetPath(guid));

            foreach (var path in hitObjectPaths)
            {
                var obj     = AssetDatabase.LoadMainAssetAtPath(path);
                var message = "該当するアセットが検出されました。" + Environment.NewLine + path;
                AddIssue(new Issue(obj, IssueLevel.Error, message, string.Empty, string.Empty));
            }
        }
コード例 #21
0
        protected override void Logic(ValidationTarget target)
        {
            foreach (var asset in target.GetAllAssets())
            {
                var clip = asset as AnimationClip;
                if (clip == null)
                {
                    continue;
                }

                LogicForAnimationClip(clip);
            }
        }
コード例 #22
0
        protected override void Logic(ValidationTarget target)
        {
            var hitObjectPaths = target.GetAllAssetGuids()
                                 .Where(targetGuid => IsUnauthorized(targetGuid, target.GetBaseFolderPath()))
                                 .Select(guid => AssetDatabase.GUIDToAssetPath(guid));

            foreach (var path in hitObjectPaths)
            {
                var obj      = AssetDatabase.LoadMainAssetAtPath(path);
                var message  = LocalizedMessage.Get("AssetGuidBlacklistRule.UnauthorizedAssetDetected", path);
                var solution = LocalizedMessage.Get("AssetGuidBlacklistRule.UnauthorizedAssetDetected.Solution");
                AddIssue(new Issue(obj, IssueLevel.Error, message, solution, string.Empty));
            }
        }
コード例 #23
0
        protected override void Logic(ValidationTarget target)
        {
            AddIssue(new Issue(
                         null,
                         IssueLevel.Info,
                         "gameObjects = " + ArrayToString(target.GetAllObjects())
                         ));

            AddIssue(new Issue(
                         null,
                         IssueLevel.Info,
                         "assets = " + ArrayToString(target.GetAllAssets())
                         ));
        }
コード例 #24
0
        protected override void Logic(ValidationTarget target)
        {
            var oversizes = target
                            .GetAllObjects()
                            .SelectMany(GetObjectBounds)
                            .Where(data => !LimitContains(data.bounds));

            foreach (var oversize in oversizes)
            {
                var limitSize = limit.size.ToString();
                var message   = string.Format("オブジェクトがブースサイズ制限{0}の外に出ています。{4}制限={1}{4}対象={2}{4}オブジェクトの種類={3}", limitSize, limit.ToString(accuracy), oversize.bounds.ToString(accuracy), oversize.objectReference.GetType().Name, System.Environment.NewLine);
                AddIssue(new Issue(oversize.objectReference, IssueLevel.Error, message));
            }
        }
コード例 #25
0
        protected override void Logic(ValidationTarget target)
        {
            var paths = target.GetAllAssetPaths();

            foreach (var path in paths)
            {
                var excess = path.Length - limit;
                if (excess > 0)
                {
                    var referenceObject = AssetDatabase.LoadMainAssetAtPath(path);
                    var message         = LocalizedMessage.Get("AssetPathLengthRule.Overlength", limit, excess, path);
                    AddIssue(new Issue(referenceObject, IssueLevel.Error, message, string.Empty));
                }
            }
        }
コード例 #26
0
ファイル: StaticFlagRule.cs プロジェクト: VitDeck/VitDeck
        protected override void Logic(ValidationTarget target)
        {
            var rootObjects = target.GetRootObjects();

            foreach (var rootObject in rootObjects)
            {
                var staticRoot = rootObject.transform.Find("Static");
                if (staticRoot == null)
                {
                    continue;
                }

                LogicForStaticRoot(staticRoot);
            }
        }
コード例 #27
0
        protected override void Logic(ValidationTarget target)
        {
            var path = target.GetBaseFolderPath();

            if (!permissionPattern.IsMatch(path))
            {
                this.AddIssue(new Issue(
                                  AssetDatabase.LoadMainAssetAtPath(path),
                                  IssueLevel.Error,
                                  "ベースフォルダのパスが規則に一致しません。",
                                  this.solution,
                                  this.solutionURL
                                  ));
            }
        }
コード例 #28
0
ファイル: BoothBoundsRule.cs プロジェクト: VitDeck/VitDeck
        protected override void Logic(ValidationTarget target)
        {
            if (indicatorResetter != null)
            {
                indicatorResetter.Reset();
            }
            indicatorResetter = new ResetTokenSource();

            var rootObjects = target.GetRootObjects();

            foreach (var rootObject in rootObjects)
            {
                LogicForRootObject(rootObject);
            }
        }
コード例 #29
0
        protected override void Logic(ValidationTarget target)
        {
            var paths = target.GetAllAssetPaths();

            foreach (var path in paths)
            {
                var excess = path.Length - limit;
                if (excess > 0)
                {
                    var referenceObject = AssetDatabase.LoadMainAssetAtPath(path);
                    var message         = System.String.Format("アセットのパスが長すぎます。(制限={0}, 超過={1}, パス={2})", limit, excess, path);
                    AddIssue(new Issue(referenceObject, IssueLevel.Error, message, string.Empty));
                }
            }
        }
コード例 #30
0
        protected override void Logic(ValidationTarget target)
        {
            var objs = target.GetAllObjects();

            bakeTypeListString = string.Join(", ", approvedLightmapBakeTypes.Select(x => x.ToString()).ToArray());

            foreach (var obj in objs)
            {
                var light = obj.GetComponent <Light>();
                if (light != null && light.type == type)
                {
                    LogicForLight(light);
                }
            }
        }