Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

Commit

Permalink
[Add]水源オブジェクトを自動で大量に設置するスクリプトを追加
Browse files Browse the repository at this point in the history
暫定として横一列のみ
  • Loading branch information
HyodaKazuaki committed Oct 15, 2018
1 parent ef98b5d commit ab4027b
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 4 deletions.
67 changes: 64 additions & 3 deletions Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1}
m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -956,6 +956,51 @@ Transform:
m_Father: {fileID: 660282287}
m_RootOrder: 39
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &470766211
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 470766213}
- component: {fileID: 470766212}
m_Layer: 0
m_Name: FlexSources
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &470766212
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 470766211}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bca0e14da3b3ec24e97c17540d0b0105, type: 3}
m_Name:
m_EditorClassIdentifier:
prefabFlexSourceActor: {fileID: 1585492102617398, guid: 2bf78e89c8a337b4cb83a21e59048d41,
type: 2}
distance: 0.5
startPosition: {x: -12, y: 9.45, z: 2.06}
count: 50
--- !u!4 &470766213
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 470766211}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &504342363
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1216,13 +1261,14 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 660282287}
- component: {fileID: 660282288}
m_Layer: 0
m_Name: FlexSources
m_Name: OldFlexSources
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!4 &660282287
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1285,6 +1331,21 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &660282288
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 660282286}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bca0e14da3b3ec24e97c17540d0b0105, type: 3}
m_Name:
m_EditorClassIdentifier:
prefabFlexSourceActor: {fileID: 0}
distance: 0.5
startPosition: {x: -8, y: 9.45, z: 2.06}
count: 50
--- !u!1 &660811761
GameObject:
m_ObjectHideFlags: 0
Expand Down
35 changes: 34 additions & 1 deletion Assets/Scripts/FlexSourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,46 @@

public class FlexSourceGenerator : MonoBehaviour {

public GameObject prefabFlexSourceActor;
public float distance = 0.5f;
public Vector3 startPosition = new Vector3(-12.0f, 9.45f, 2.06f);
public RandomRange randomRange = new RandomRange(-1.0f, 1.0f);
public int count = 50;

// Use this for initialization
void Start () {

for(int i = 0; i < count; i++)
{
GameObject obj = Instantiate(prefabFlexSourceActor, new Vector3(startPosition.x + distance * i, startPosition.y + Random.Range(randomRange.Min, randomRange.Max), startPosition.z), Quaternion.identity);
obj.transform.parent = transform;
}
}

// Update is called once per frame
void Update () {

}
}

public class RandomRange {
private float _min;
private float _max;

public RandomRange(float min, float max)
{
_min = (min < max) ? min : max;
_max = (min < max) ? max : min;
}

public float Min
{
set { _min = (value < _max) ? value : _min; }
get { return _min; }
}

public float Max
{
set { _max = (value > _min) ? value : _max; }
get { return _max; }
}
}

0 comments on commit ab4027b

Please sign in to comment.