Ejemplo n.º 1
0
 public override void OnInspectorGUI()
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("Length: " + line.CurveLength().ToString());
     EditorGUILayout.LabelField("Segments: " + line.CurveCount.ToString());
     EditorGUILayout.EndHorizontal();
 }
        private DecoratorGameObject[] GetGameObjectsToAdd()
        {
            List <DecoratorGameObject> gameObjects = new List <DecoratorGameObject>();

            if (startGameObject != null)
            {
                gameObjects.Add(new DecoratorGameObject(startGameObject, 1));
            }

            if (endGameObject != null)
            {
                gameObjects.Add(new DecoratorGameObject(endGameObject, 1));
            }

            float remainingDistance = curve.CurveLength() - GetGameObjectsLength(gameObjects.ToArray());
            int   middleStartIndex  = startGameObject != null ? 1 : 0;

            if (middleGameObject != null)
            {
                float middleLength    = middleGameObject.GetComponent <MeshFilter>().sharedMesh.bounds.size.x;
                float middleCount     = remainingDistance / middleLength;
                int   fullMiddleCount = Mathf.FloorToInt(middleCount);

                float middleScale = 1 + (middleCount % 1) / fullMiddleCount;

                for (int i = 0; i < fullMiddleCount; i++)
                {
                    gameObjects.Insert(middleStartIndex, new DecoratorGameObject(middleGameObject, middleScale));
                }
            }


            return(gameObjects.ToArray());
        }