Exemple #1
0
        /// <summary>
        /// Remove prefabs
        /// </summary>
        private void RemovePrefabs(Vector3 position)
        {
            if (!editor.IsEditorSettingsValid())
            {
                return;
            }

            // check if a gameobject of the container is within the brush size and remove it
            GameObject container = gizmo.container as GameObject;

            float radius = gizmo.brushSettings.brushSize / 2f;

            List <Transform> removeList = new List <Transform>();

            foreach (Transform transform in container.transform)
            {
                float dist = Vector3.Distance(position, transform.transform.position);

                if (dist <= radius)
                {
                    removeList.Add(transform);
                }
            }

            // remove gameobjects
            foreach (Transform transform in removeList)
            {
                PrefabPainter.DestroyImmediate(transform.gameObject);
            }
        }
Exemple #2
0
        private void RemoveAllPrefabInstances()
        {
            foreach (GameObject prefab in prefabPainter.splineSettings.prefabInstances)
            {
                PrefabPainter.DestroyImmediate(prefab);
            }

            prefabPainter.splineSettings.prefabInstances.Clear();
        }
        private void ClearSpline(bool removePrefabInstances)
        {
            gizmo.splineSettings.controlPoints.Clear();

            if (removePrefabInstances)
            {
                foreach (GameObject go in gizmo.splineSettings.prefabInstances)
                {
                    PrefabPainter.DestroyImmediate(go);
                }
            }

            gizmo.splineSettings.prefabInstances.Clear();

            gizmo.splineSettings.controlPoints.Clear();
        }
Exemple #4
0
        private void ClearSpline(bool removePrefabInstances)
        {
            editorTarget.splineSettings.controlPoints.Clear();

            if (removePrefabInstances)
            {
                foreach (GameObject go in editorTarget.splineSettings.prefabInstances)
                {
                    PrefabPainter.DestroyImmediate(go);
                }
            }

            editorTarget.splineSettings.prefabInstances.Clear();

            editorTarget.splineSettings.controlPoints.Clear();

            editorTarget.splineSettings.dirty = true;
        }
Exemple #5
0
        private void RemovePrefabInstances(int startIndex)
        {
            // startIndex might be -1 if there are no prefabs; prefabInstanceIndex would be -1
            // also needed if you delete control points and only 1 is left
            if (startIndex < 0)
            {
                RemoveAllPrefabInstances();
                return;
            }

            // clear existing prefabs
            for (int i = prefabPainter.splineSettings.prefabInstances.Count - 1; i >= startIndex; i--)
            {
                GameObject prefab = prefabPainter.splineSettings.prefabInstances[i];

                PrefabPainter.DestroyImmediate(prefab);

                prefabPainter.splineSettings.prefabInstances.RemoveAt(i);
            }
        }