Example #1
0
        public void DrawRegisterPrefabsBox()
        {
            EditorGUILayout.BeginVertical(GPUInstancerEditorConstants.Styles.box);
            GPUInstancerEditorConstants.DrawCustomLabel(GPUInstancerEditorConstants.TEXT_registeredPrefabs, GPUInstancerEditorConstants.Styles.boldLabel);
            GPUInstancerEditorConstants.DrawColoredButton(GPUInstancerEditorConstants.Contents.registerPrefabsInScene, GPUInstancerEditorConstants.Colors.darkBlue, Color.white, FontStyle.Bold, Rect.zero,
                                                          () =>
            {
                Undo.RecordObject(_prefabManager, "Register prefabs in scene");
                _prefabManager.RegisterPrefabsInScene();
            });
            DrawHelpText(GPUInstancerEditorConstants.HELPTEXT_registerPrefabsInScene);

            if (!Application.isPlaying && _prefabManager.registeredPrefabs.Count > 0)
            {
                foreach (RegisteredPrefabsData rpd in _prefabManager.registeredPrefabs)
                {
                    GPUInstancerEditorConstants.DrawCustomLabel(rpd.prefabPrototype.ToString() + " Instance Count: " +
                                                                rpd.registeredPrefabs.Count,
                                                                GPUInstancerEditorConstants.Styles.label, false);
                }
            }
            else if (Application.isPlaying && _prefabManager.GetRegisteredPrefabsRuntimeData() != null && _prefabManager.GetRegisteredPrefabsRuntimeData().Count > 0)
            {
                foreach (GPUInstancerPrototype p in _prefabManager.GetRegisteredPrefabsRuntimeData().Keys)
                {
                    GPUInstancerEditorConstants.DrawCustomLabel(p.ToString() + " Instance Count: " +
                                                                _prefabManager.GetRegisteredPrefabsRuntimeData()[p].Count,
                                                                GPUInstancerEditorConstants.Styles.label, false);
                }
            }
            else
            {
                GPUInstancerEditorConstants.DrawCustomLabel("No registered prefabs.", GPUInstancerEditorConstants.Styles.label, false);
            }

            EditorGUILayout.EndVertical();
        }