コード例 #1
0
        private static void AddObjectsToGroup(ThemeGroup group)
        {
            foreach (var go in Selection.gameObjects)
            {
                var prefabMode = PrefabStageUtility.GetCurrentPrefabStage();
                if (prefabMode)
                {
                    var data = new PrefabObject(prefabMode.assetPath, GetPath(go));
                    group.prefabObjects.Add(data);
                    continue;
                }

                group.objects.Add(go);
            }
        }
コード例 #2
0
        private void OnGUI()
        {
            if (GUILayout.Button("Add new group"))
            {
                var group = new ThemeGroup();
                AddObjectsToGroup(group);
                groups.Add(group);
            }

            foreach (var group in groups)
            {
                EditorGUILayout.Separator();
                DrawGroup(group);
            }

            groups.RemoveAll(g => g.removed);
        }
コード例 #3
0
        private void AssignColor(ThemeGroup group)
        {
            var color = group.color;

            foreach (var obj in group.objects)
            {
                if (obj)
                {
                    AssignColor(obj, color);
                }
            }

            foreach (var data in group.prefabObjects)
            {
                var go = AssetDatabase.LoadAssetAtPath <GameObject>(data.asset);
                var t  = FindNext(go.transform, WithoutFirst(data.path));
                AssignColor(t.gameObject, group.color);
                AssetDatabase.SaveAssets();
            }
        }
コード例 #4
0
        private void DrawGroup(ThemeGroup group)
        {
            EditorGUILayout.LabelField($"Group of {group.ObjectCount}");

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Select"))
            {
                Selection.objects = group.objects.ToArray();
            }

            if (GUILayout.Button("Set"))
            {
                group.objects.Clear();
                group.prefabObjects.Clear();
                AddObjectsToGroup(group);
            }

            if (GUILayout.Button("Add"))
            {
                AddObjectsToGroup(group);
            }

            if (GUILayout.Button("Remove"))
            {
                group.removed = true;
            }

            EditorGUILayout.EndHorizontal();

            EditorGUI.BeginChangeCheck();

            group.color = EditorGUILayout.ColorField(group.color);

            if (EditorGUI.EndChangeCheck())
            {
                AssignColor(group);
            }
        }