Browse Source
The same effect can easily be achieved with Views or by creating a very simple UI Canvas and Image.master
chrisgregan
10 years ago
7 changed files with 170 additions and 490 deletions
@ -1,42 +0,0 @@ |
|||||||
using UnityEngine; |
|
||||||
using System; |
|
||||||
using System.Collections; |
|
||||||
|
|
||||||
namespace Fungus |
|
||||||
{ |
|
||||||
[CommandInfo("Dialog", |
|
||||||
"Set Background", |
|
||||||
"Draws a fullscreen background texture using a Background UI object.")] |
|
||||||
public class SetBackground : Command |
|
||||||
{ |
|
||||||
public Background background; |
|
||||||
|
|
||||||
public Sprite backgroundImage; |
|
||||||
|
|
||||||
public override void OnEnter() |
|
||||||
{ |
|
||||||
if (background != null) |
|
||||||
{ |
|
||||||
background.SetBackgroundImage(backgroundImage); |
|
||||||
} |
|
||||||
|
|
||||||
Continue(); |
|
||||||
} |
|
||||||
|
|
||||||
public override string GetSummary() |
|
||||||
{ |
|
||||||
if (backgroundImage == null) |
|
||||||
{ |
|
||||||
return "<None>"; |
|
||||||
} |
|
||||||
|
|
||||||
return backgroundImage.name; |
|
||||||
} |
|
||||||
|
|
||||||
public override Color GetButtonColor() |
|
||||||
{ |
|
||||||
return new Color32(184, 210, 235, 255); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,8 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: 2d0318fa6f5b342c4abfe47bfd0ee062 |
|
||||||
MonoImporter: |
|
||||||
serializedVersion: 2 |
|
||||||
defaultReferences: [] |
|
||||||
executionOrder: 0 |
|
||||||
icon: {instanceID: 0} |
|
||||||
userData: |
|
@ -1,166 +0,0 @@ |
|||||||
%YAML 1.1 |
|
||||||
%TAG !u! tag:unity3d.com,2011: |
|
||||||
--- !u!1 &100000 |
|
||||||
GameObject: |
|
||||||
m_ObjectHideFlags: 0 |
|
||||||
m_PrefabParentObject: {fileID: 0} |
|
||||||
m_PrefabInternal: {fileID: 100100000} |
|
||||||
serializedVersion: 4 |
|
||||||
m_Component: |
|
||||||
- 4: {fileID: 400000} |
|
||||||
- 114: {fileID: 11400000} |
|
||||||
m_Layer: 0 |
|
||||||
m_Name: Background |
|
||||||
m_TagString: Untagged |
|
||||||
m_Icon: {fileID: 0} |
|
||||||
m_NavMeshLayer: 0 |
|
||||||
m_StaticEditorFlags: 0 |
|
||||||
m_IsActive: 1 |
|
||||||
--- !u!1 &100002 |
|
||||||
GameObject: |
|
||||||
m_ObjectHideFlags: 1 |
|
||||||
m_PrefabParentObject: {fileID: 0} |
|
||||||
m_PrefabInternal: {fileID: 100100000} |
|
||||||
serializedVersion: 4 |
|
||||||
m_Component: |
|
||||||
- 224: {fileID: 22400000} |
|
||||||
- 222: {fileID: 22200000} |
|
||||||
- 114: {fileID: 11400002} |
|
||||||
m_Layer: 5 |
|
||||||
m_Name: Image |
|
||||||
m_TagString: Untagged |
|
||||||
m_Icon: {fileID: 0} |
|
||||||
m_NavMeshLayer: 0 |
|
||||||
m_StaticEditorFlags: 0 |
|
||||||
m_IsActive: 1 |
|
||||||
--- !u!1 &100004 |
|
||||||
GameObject: |
|
||||||
m_ObjectHideFlags: 0 |
|
||||||
m_PrefabParentObject: {fileID: 0} |
|
||||||
m_PrefabInternal: {fileID: 100100000} |
|
||||||
serializedVersion: 4 |
|
||||||
m_Component: |
|
||||||
- 224: {fileID: 22400002} |
|
||||||
- 223: {fileID: 22300000} |
|
||||||
m_Layer: 5 |
|
||||||
m_Name: Canvas |
|
||||||
m_TagString: Untagged |
|
||||||
m_Icon: {fileID: 0} |
|
||||||
m_NavMeshLayer: 0 |
|
||||||
m_StaticEditorFlags: 0 |
|
||||||
m_IsActive: 0 |
|
||||||
--- !u!4 &400000 |
|
||||||
Transform: |
|
||||||
m_ObjectHideFlags: 1 |
|
||||||
m_PrefabParentObject: {fileID: 0} |
|
||||||
m_PrefabInternal: {fileID: 100100000} |
|
||||||
m_GameObject: {fileID: 100000} |
|
||||||
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: |
|
||||||
- {fileID: 22400002} |
|
||||||
m_Father: {fileID: 0} |
|
||||||
m_RootOrder: 0 |
|
||||||
--- !u!114 &11400000 |
|
||||||
MonoBehaviour: |
|
||||||
m_ObjectHideFlags: 1 |
|
||||||
m_PrefabParentObject: {fileID: 0} |
|
||||||
m_PrefabInternal: {fileID: 100100000} |
|
||||||
m_GameObject: {fileID: 100000} |
|
||||||
m_Enabled: 1 |
|
||||||
m_EditorHideFlags: 0 |
|
||||||
m_Script: {fileID: 11500000, guid: 41a94ec543d634ff782c8c704e8b6eb4, type: 3} |
|
||||||
m_Name: |
|
||||||
m_EditorClassIdentifier: |
|
||||||
backgroundCanvas: {fileID: 22300000} |
|
||||||
backgroundImage: {fileID: 11400002} |
|
||||||
--- !u!114 &11400002 |
|
||||||
MonoBehaviour: |
|
||||||
m_ObjectHideFlags: 1 |
|
||||||
m_PrefabParentObject: {fileID: 0} |
|
||||||
m_PrefabInternal: {fileID: 100100000} |
|
||||||
m_GameObject: {fileID: 100002} |
|
||||||
m_Enabled: 1 |
|
||||||
m_EditorHideFlags: 0 |
|
||||||
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} |
|
||||||
m_Name: |
|
||||||
m_EditorClassIdentifier: |
|
||||||
m_Mat: {fileID: 0} |
|
||||||
m_Color: {r: 1, g: 1, b: 1, a: 1} |
|
||||||
m_Sprite: {fileID: 21300000, guid: ea8f56c43254d41728f5ac4e8299b6c9, type: 3} |
|
||||||
m_Type: 0 |
|
||||||
m_PreserveAspect: 1 |
|
||||||
m_FillCenter: 1 |
|
||||||
m_FillMethod: 4 |
|
||||||
m_FillAmount: 1 |
|
||||||
m_FillClockwise: 1 |
|
||||||
m_FillOrigin: 0 |
|
||||||
--- !u!222 &22200000 |
|
||||||
CanvasRenderer: |
|
||||||
m_ObjectHideFlags: 1 |
|
||||||
m_PrefabParentObject: {fileID: 0} |
|
||||||
m_PrefabInternal: {fileID: 100100000} |
|
||||||
m_GameObject: {fileID: 100002} |
|
||||||
--- !u!223 &22300000 |
|
||||||
Canvas: |
|
||||||
m_ObjectHideFlags: 1 |
|
||||||
m_PrefabParentObject: {fileID: 0} |
|
||||||
m_PrefabInternal: {fileID: 100100000} |
|
||||||
m_GameObject: {fileID: 100004} |
|
||||||
m_Enabled: 1 |
|
||||||
serializedVersion: 2 |
|
||||||
m_RenderMode: 0 |
|
||||||
m_Camera: {fileID: 0} |
|
||||||
m_PlaneDistance: 100 |
|
||||||
m_PixelPerfect: 0 |
|
||||||
m_ReceivesEvents: 1 |
|
||||||
m_SortingLayerID: 0 |
|
||||||
m_SortingOrder: 0 |
|
||||||
--- !u!224 &22400000 |
|
||||||
RectTransform: |
|
||||||
m_ObjectHideFlags: 1 |
|
||||||
m_PrefabParentObject: {fileID: 0} |
|
||||||
m_PrefabInternal: {fileID: 100100000} |
|
||||||
m_GameObject: {fileID: 100002} |
|
||||||
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: 22400002} |
|
||||||
m_RootOrder: 0 |
|
||||||
m_AnchorMin: {x: 0, y: 0} |
|
||||||
m_AnchorMax: {x: 1, y: 1} |
|
||||||
m_AnchoredPosition: {x: 0, y: -.25} |
|
||||||
m_SizeDelta: {x: 0, y: .5} |
|
||||||
m_Pivot: {x: .5, y: .5} |
|
||||||
--- !u!224 &22400002 |
|
||||||
RectTransform: |
|
||||||
m_ObjectHideFlags: 1 |
|
||||||
m_PrefabParentObject: {fileID: 0} |
|
||||||
m_PrefabInternal: {fileID: 100100000} |
|
||||||
m_GameObject: {fileID: 100004} |
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|
||||||
m_LocalScale: {x: 0, y: 0, z: 0} |
|
||||||
m_Children: |
|
||||||
- {fileID: 22400000} |
|
||||||
m_Father: {fileID: 400000} |
|
||||||
m_RootOrder: 0 |
|
||||||
m_AnchorMin: {x: 0, y: 0} |
|
||||||
m_AnchorMax: {x: 0, y: 0} |
|
||||||
m_AnchoredPosition: {x: 0, y: 0} |
|
||||||
m_SizeDelta: {x: 0, y: 0} |
|
||||||
m_Pivot: {x: 0, y: 0} |
|
||||||
--- !u!1001 &100100000 |
|
||||||
Prefab: |
|
||||||
m_ObjectHideFlags: 1 |
|
||||||
serializedVersion: 2 |
|
||||||
m_Modification: |
|
||||||
m_TransformParent: {fileID: 0} |
|
||||||
m_Modifications: [] |
|
||||||
m_RemovedComponents: [] |
|
||||||
m_ParentPrefab: {fileID: 0} |
|
||||||
m_RootGameObject: {fileID: 100000} |
|
||||||
m_IsPrefabParent: 1 |
|
||||||
m_IsExploded: 1 |
|
@ -1,4 +0,0 @@ |
|||||||
fileFormatVersion: 2 |
|
||||||
guid: a276a1108d4ee4da695983af7ae56c2e |
|
||||||
NativeFormatImporter: |
|
||||||
userData: |
|
@ -1,22 +0,0 @@ |
|||||||
using UnityEngine; |
|
||||||
using UnityEngine.UI; |
|
||||||
using System.Collections; |
|
||||||
|
|
||||||
public class Background : MonoBehaviour |
|
||||||
{ |
|
||||||
public Canvas backgroundCanvas; |
|
||||||
public Image backgroundImage; |
|
||||||
|
|
||||||
public virtual void SetBackgroundImage(Sprite imageSprite) |
|
||||||
{ |
|
||||||
if (backgroundCanvas != null) |
|
||||||
{ |
|
||||||
backgroundCanvas.gameObject.SetActive(imageSprite != null); |
|
||||||
} |
|
||||||
|
|
||||||
if (backgroundImage != null) |
|
||||||
{ |
|
||||||
backgroundImage.sprite = imageSprite; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue