Exemplo n.º 1
0
        public static IEnumerable <KeyValuePair <GameObject, CSGTreeBrushIntersection> > GetAllOverlapping(Vector2 position)
        {
            var allOverlapping = new List <GameObject>();

            while (true)
            {
                GameObject[]             ignore = allOverlapping.ToArray();
                GameObject[]             filter = null;
                CSGTreeBrushIntersection intersection;
                var go = PickClosestGameObjectDelegated(position, ref ignore, ref filter, out intersection);
                if (go == null)
                {
                    break;
                }

                if (allOverlapping.Count > 0 && allOverlapping.Contains(go))
                {
                    break;
                }

                if (!CSGGeneratedComponentManager.IsObjectGenerated(go))
                {
                    yield return(new KeyValuePair <GameObject, CSGTreeBrushIntersection>(go, intersection));
                }

                allOverlapping.Add(go);
            }
        }
Exemplo n.º 2
0
        public static bool IsPartOfDefaultModel(UnityEngine.Object[] targetObjects)
        {
            if (targetObjects == null)
            {
                return(false);
            }

            for (int i = 0; i < targetObjects.Length; i++)
            {
                CSGNode node = targetObjects[i] as CSGNode;
                if (Equals(node, null))
                {
                    var gameObject = targetObjects[i] as GameObject;
                    if (gameObject)
                    {
                        node = gameObject.GetComponent <CSGNode>();
                    }
                }
                if (node)
                {
                    if (CSGGeneratedComponentManager.IsDefaultModel(node.hierarchyItem.Model))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        bool IsDefaultModel()
        {
            if (serializedObject.targetObjects == null)
            {
                return(false);
            }

            for (int i = 0; i < serializedObject.targetObjects.Length; i++)
            {
                if (CSGGeneratedComponentManager.IsDefaultModel(serializedObject.targetObjects[i]))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 4
0
        internal static GameObject PickModel(Camera camera, Vector2 pickposition, int layers, ref GameObject[] ignore, ref GameObject[] filter, out CSGModel model, out Material material)
        {
            model    = null;
            material = null;
            var        flagState       = CSGGeneratedComponentManager.BeginPicking();
            GameObject gameObject      = null;
            bool       foundGameObject = false;

            try
            {
                int materialIndex = -1;
                if (pickClosestGO == null ||
                    pickClosestGameObjectDelegate == null)
                {
                    gameObject = HandleUtility.PickGameObject(pickposition, ignore, out materialIndex);
                }
                else
                {
                    gameObject = pickClosestGO(camera, layers, pickposition, ignore, filter, out materialIndex);
                }
            }
            finally
            {
                foundGameObject = CSGGeneratedComponentManager.EndPicking(flagState, gameObject, out model) && model;
            }
            if (object.Equals(gameObject, null))
            {
                return(null);
            }

            if (!foundGameObject)
            {
                return(gameObject);
            }

            var renderer = gameObject.GetComponent <Renderer>();

            if (renderer)
            {
                material = renderer.sharedMaterial;
                if (!material)
                {
                    material = null;
                }
            }
            return(gameObject);
        }
Exemplo n.º 5
0
        static bool RemoveGeneratedMeshesFromArray(ref UnityEngine.Object[] selection)
        {
            var found = new List <UnityEngine.Object>();

            for (int i = selection.Length - 1; i >= 0; i--)
            {
                var obj = selection[i];
                if (CSGGeneratedComponentManager.IsObjectGenerated(obj))
                {
                    continue;
                }
                found.Add(obj);
            }
            if (selection.Length != found.Count)
            {
                selection = found.ToArray();
                return(true);
            }
            return(false);
        }
Exemplo n.º 6
0
        bool NeedLightmapRebuild()
        {
            if (target == null)
            {
                return(false);
            }

            foreach (var target in targets)
            {
                var model = target as CSGModel;
                if (!model)
                {
                    continue;
                }
                if (CSGGeneratedComponentManager.NeedUVGeneration(model))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 7
0
        void RenderMeshSettingsGUI()
        {
            if (serializedObject == null || gameObjectsSerializedObject == null || gameObjectsSerializedObject.targetObjects.Length == 0)
            {
                return;
            }

            gameObjectsSerializedObject.Update();

#if UNITY_2018_2_OR_ABOVE
            if (SupportedRenderingFeatures.active.rendererSupportsMotionVectors)
#endif
            EditorGUILayout.PropertyField(motionVectorsProp, MotionVectorsContent, true);

            EditorGUILayout.Space();
            LightmapStaticSettings();

            if (!(Lightmapping.bakedGI || Lightmapping.realtimeGI) && !IsPrefabAsset)
            {
                EditorGUILayout.HelpBox(GINotEnabledInfoContents.text, MessageType.Info);
                return;
            }

            bool enableSettings = (staticEditorFlagsProp.intValue & (int)StaticEditorFlags.LightmapStatic) != 0;
            if (enableSettings)
            {
                EditorGUILayout.Space();
                var needLightmapRebuild = NeedLightmapRebuild();
                if (!autoRebuildUVsProp.boolValue && needLightmapRebuild)
                {
                    EditorGUILayout.HelpBox(NeedsLightmapRebuildContents.text, MessageType.Warning);
                }

                var buttonRect     = EditorGUILayout.GetControlRect();
                int buttonId       = EditorGUIUtility.GetControlID(RebuildButtonHashCode, FocusType.Keyboard, buttonRect);
                var buttonPropRect = EditorGUI.PrefixLabel(buttonRect, buttonId, LightmapUVsContents);
                var buttonContents = needLightmapRebuild ? ForceBuildUVsContents : ForceRebuildUVsContents;
                if (GUI.Button(buttonPropRect, buttonContents))
                {
                    CSGGeneratedComponentManager.DelayedUVGeneration(force: true);
                }
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(autoRebuildUVsProp, AutoRebuildUVsContents);
                if (EditorGUI.EndChangeCheck())
                {
                    if (autoRebuildUVsProp.boolValue)
                    {
                        CSGGeneratedComponentManager.ForceUpdateDelayedUVGeneration();
                    }
                }

                showUnwrapParams = EditorGUILayout.Foldout(showUnwrapParams, UnwrapParamsContents, true);
                if (showUnwrapParams)
                {
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.PropertyField(angleErrorProp);
                    EditorGUILayout.PropertyField(areaErrorProp);
                    EditorGUILayout.PropertyField(hardAngleProp);
                    EditorGUILayout.PropertyField(packMarginPixelsProp);
                    EditorGUI.indentLevel -= 1;
                }

#if UNITY_2017_2_OR_ABOVE
                showEnlightenSettings = IsPrefabAsset || Lightmapping.realtimeGI || (Lightmapping.bakedGI && LightmapEditorSettings.lightmapper == (Lightmapper)0);
                var showProgressiveSettings = IsPrefabAsset || (Lightmapping.bakedGI && LightmapEditorSettings.lightmapper != (Lightmapper)0);
#else
                bool showEnlightenSettings = IsPrefabAsset || Lightmapping.realtimeGI || Lightmapping.bakedGI;
#endif

                if (showEnlightenSettings)
                {
                    showChartingSettings = EditorGUILayout.Foldout(showChartingSettings, UVChartingContents, true);
                    if (showChartingSettings)
                    {
                        RendererUVSettings();
                    }
                }

                showLightmapSettings = EditorGUILayout.Foldout(showLightmapSettings, LightmapSettingContents, true);
                if (showLightmapSettings)
                {
                    EditorGUI.indentLevel += 1;

                    float lightmapScale = LightmapScaleGUI(1.0f);

                    ShowClampedSizeInLightmapGUI(lightmapScale);

                    if (showEnlightenSettings)
                    {
                        EditorGUILayout.PropertyField(importantGIProp, ImportantGIContents);
                    }

#if UNITY_2017_2_OR_ABOVE
                    if (showProgressiveSettings)
                    {
                        EditorGUILayout.PropertyField(stitchLightmapSeamsProp, StitchLightmapSeamsContents);
                    }
#endif

                    if (LightmapParametersGUI != null)
                    {
                        LightmapParametersGUI(lightmapParametersProp, LightmapParametersContents);
                    }

                    EditorGUI.indentLevel -= 1;
                }

                if (TargetsHaveClampedResolution())
                {
                    EditorGUILayout.HelpBox(ClampedPackingResolutionContents.text, MessageType.Warning);
                }

                if ((vertexChannelMaskProp.intValue & (int)VertexChannelFlags.Normal) != (int)VertexChannelFlags.Normal)
                {
                    EditorGUILayout.HelpBox(NoNormalsNoLightmappingContents.text, MessageType.Warning);
                }

                if (TargetsHaveUVOverlaps())
                {
                    EditorGUILayout.HelpBox(UVOverlapContents.text, MessageType.Warning);
                }

                serializedObject.ApplyModifiedProperties();
            }
            else
            {
                EditorGUILayout.HelpBox(LightmapInfoBoxContents.text, MessageType.Info);
            }
        }